Search code examples
javascriptjqueryhtmlmasking

maskMoney Jquery Bug when using append


I have html like this, actually input inside tr of table:

<input type='text' class='angka1' style='text-align:right;' name='Nominal"+a+"' required/>

And i have a javascript like this in when document ready:

enter image description here

When i try to append just 1 row, nothing wrong, i can input number formatted correctly. But, when i try to append more than 1, like 2 rows, i try to input '1'. than i will get '11'.

I get word like long of the row i have inputted. How can i fix it?, or do you have any solution to create object formatted like #.###,##. (Sorry many of tags in html i deleted, i am very beginner in stackoverflow)


Solution

  • You need to use $('.angka' + i).maskMoney() instead of $('.angka1').maskMoney() and move statement i++ after the statement