i have list of dynamic generated buttons and id is generated on run time. how can is get id of clicked button using JQuery.
Here is js code
var btn = " <input type='button' id='btnDel' value='Delete' />";
$("#metainfo").append(txt); //set value of
$("#btnDel").attr("id", "btnDel" + $("#hid").attr("value"));
For your example it would be like this:
Note that you can’t loop the code you have, IDs have to be unique, you’ll get all sorts of side-effects if they’re not, as it’s invalid HTML. If you wanted a click handler for any input, change the selector, like this: