0
Good night, you guys,
I have a code that uses maskmoney.
I’m using cloneNode to copy a div, it works, but the input I use maskmoney does not work in the copied fields.
Someone can help ?
//script mask money
$(document).ready(function(){
$("#valor").maskMoney({showSymbol:true, symbol:"R$", decimal:".", thousands:""});
});
Here is the clone function
<script>
function duplicarCampos(){
var clone = document.getElementById('origem').cloneNode(true);
var destino = document.getElementById('destino');
destino.appendChild (clone);
var camposClonados = clone.getElementsByTagName('input');
for(i=0; i<camposClonados.length;i++){
camposClonados[i].value = '';
}
}
function removerCampos(id){
var node1 = document.getElementById('destino');
node1.removeChild(node1.childNodes[0]);
}
Here is the input I use maskmoney
<input type="text" name="valor[]" id="valor" style="text-align:center; width: 20%"/>
clone an element with
maskMoney
will not make the cloned element behave the same, it is necessary to apply themaskMoney
to the new element– Ricardo Pontual