I have this code:
HTML:
<div class="formElement" id="debtors">
<label> Debtors</label>
<input type="text" name="debtors">
<button id="btnClicker" onclick="test()">Append list items</button>
</div>
and jquery:
test= function(){
var clicked = 0;
$("#btnClicker").click(function(){
clicked++;
$("#debtors").append("<input type=\"text\" name=\"test"+clicked+"\" value=\"test\" />");
});
};
The problem is that when the function is executed the input box is not shown at the 1st click and after the 2nd click there are 2 input boxes added and after few more clicks the boxes are duplicated for a strange reason. I tried almost everything that I found online, but it seems that I'm still new in jquery. I'm opretty sure that I'm missing something small. Do you have any fix ideas?