1
I need help cloning an already created element dynamically with Jquery and adding +1 in value and element name.
else if(valorSelect == 'listaSuspensa'){
$(this).parents(".questionario").find('.divResposta').html(
'<div class="divListaSuspensa">'+
'<ol>'+
'<div class="NomearOpcaoLS">'+
'<li><input class="w3-
input w3-left" type="text" name="txtMultiplaEscolha" value="Opção 1"
style="width:90%">'+
'<a id="id_ExcluirRespostaLS" class="excluirLS w3-
right w3-bar-item w3-button w3-right" style="color: grey;"><i
class="material-icons">close</i></a></li><br><br>'+
'<li><a class="AddQtdLS">Adicionar opção</a></li>'+
'</div>'+
'</ol>'+
'</div>'
);
The element I would like to clone is the first 'li', and add just below.
$('.Nameopleols > li:first-Child'). clone(). appendTo('.Nameopleols'); $('.Nameopleols > li:last-Child > input'). attr('id', 'Newid'). val('XYZ');
– Don't Panic
It worked, only in case I’ll have other Divs with the same elements then how do I clone only in the div that I am?
– wolf