I have a product values registration page, where I have an input field with a value mask in R $. But since this field is created dynamically after a search in the bd, the mask is only working on the first input. I know of a solution but it does not become friendly besides making the page slow. He wanted a practical and workable solution. Follow the code.
HTML:
<?php foreach ($produtos as $produto) {
echo "<div class='produtos'>
<div style='float:left;'><img src=".base_url()."uploads/produtos/".$produto->foto." title=".$produto->nome."></div>
<div class='descricao_produto'>
<font size='4'>".$produto->nome."</font><br>
<font size='2'>".$produto->descricao."</font><br>
<input type='text' name='preco_produto' style='width:60px;' value='' placeholder='Preço' id='preco'>
</div>
</div>";
} ?>
JS:
$(document).ready(function(){
$("#preco").maskMoney({symbol:'R$ ',
showSymbol:true, thousands:'.', decimal:',', symbolStay: true});
});