I'm using the append method to add some input fields and a button to form, if the user needs to add more info. Each button has different different name and id, but same class.
The append process is working fine, but when I want to remove a specific field using the new button it does not work. The click action works for the first button, which is exists by default, but now for buttons added at run time.
rc; //is the counter which increments by one, each time.
jQuery('#mytable').append("<div id='rev-" + rc + "' class='reviewer'>" +
"<input type='text' name='reviewer_email[]' id='reviewer_email" + rc + "' value='' />" +
"<input type='button' name='rd" + rc + "' id='rd" + rc + "' class='rrd' value='Remove' /></div>");
jQuery(".rrd").click(function(){
alert("Test");
});
I have searched for solution, first I was using the same id for all buttons but now I'm using same class for each button instead of id.
Can anyone give an idea, where I'm going wrong.
The above code is not the exact code, but idea, how I'm using it.
Thanks.