1
On my PHP and Javascript page, I created a space that contains two Textbox and a clickable label to add more Textbox, if necessary, to div numPart:
<div id="numPart">
<div class="inputMGM"><input name="part" id="" class="validate[required]"></input></div>
<div class="inputMGM"><input name="part" id="" class="validate[required]"></input></div>
</div>
<label id="addPart" class="SpaceEnviar" style="cursor: pointer; decoration: underline">ADICIONAR PARTICIPANTE</label>
And the function that adds more textbox is as follows.
var x=1;
$("#addPart").click(function(){
var d = document.getElementById('numPart');
d.innerHTML += "<div class='inputMGM'><input name='part' id='' class='validate[required]'></input></div>";
});
However, if I have filled in some of the existing Textbox and clicked to add one more, the existing text I filled in goes away.
How can I keep the texts written in the existing Textbox as I click to add more to the form?
Great idea to use the
last()
. +1– Pedro Camara Junior
Thank you @Pedrocamarajunior
– Miguel