I have a code where there is a form and the user can choose the number of lines by clicking on the buttons that are in front of the input, there is a '+' button to add a new input and '-' to remove the current input.
Follow the code:
<div class="posicao-radioButton botoes">
<div class="input">
<input type="radio" disabled name="idade"><input type="text"
name="quest1"><a href=""><img class="img-add" title="Adicionar uma
linha" src="img/add.png"></a><a href=""><img class="img-remove"
title="Remover Linha" src="img/remove.png"></a>
</div>
</div>
These buttons are connected with jquery events that will add a line every time you click it.
$(function(){
$(".img-add").click(function(e){
event.preventDefault();
console.log("click");
var parente = $(this).closest(".input");
parente.clone().appendTo( ".botoes" );
})
})
however this code is only partially working, since the event works only for the first button that is created with the page and not with the others. Does anyone know what is missing to run the event on all buttons that are created?
Thank you.