Arson speaks, all beauty? (:
Dude, I don’t know how I would do with jQuery, but in pure Javascript from the Ecmascript 6 has a specific feature to make this conversion, and it has some nice attributes. Follow the example:
First I declare a variable, which will receive the value in cash (in our example, 1,000.00).
var din = 1000;
After that, I will invoke the functionality that will perform this conversion, passing our variable declared above by parameter:
new Intl.NumberFormat('pt-BR',
{ style: 'currency', currency: 'BRL' }
).format(din); // "R$ 1.000,00"
Ready! The function will return the formatted value and converted into Real. (:
You can change the attributes to convert to other currencies around the world. And it’s okay to use it with your jQuery code, after all, it’s all Javascript. xd
If you want to know a little more about, I’ll leave here the link of the article I read talking about, follows: https://www.samanthaming.com/tidbits/30-how-to-format-currency-in-es6/
I hope I helped, hugging!
the live part doesn’t work using it $( '#price' ).keyup( Function() { $('#price'). Mask("#. ###,##", {Reverse: true}); });
– Arsom Nolasco
no need to use keyup, it does automatically, just need to apply the mask in the input
– Igor Oliveira