1

is it possible to replace a string in the current tag using jquery like this:

<td class="price"><script>$(this).text(accounting.formatMoney(parseFloat({{ product.price }}).toFixed(2), "€ ", 2, ".", ","));</script></td>

actually this doesn't work.

thanks in advance!

1 Answer 1

2

You could set it up in a function to do, but not until after the page loads... something like this is what you're looking for... First, change your HTML:

<td class="price">{{ product.price }}</td>

Then this script should work for you:

$(function(){
    $('.price').each(function(){
        var price = $(this).text()
        $(this).text(accounting.formatMoney(parseFloat(price).toFixed(2), "€ ", 2, ".", ","))
    });
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.