You can bind all buttons with a click event like this, there is no need to loop through them
$(function(){ $("button").click(function() { alert($(this).attr("value")); }); });
But a more precise selector might be:
$(function(){ $("button[id^='button-'").click(function() { alert($(this).attr("value")); }); });
Read full article from jquery - each / click function not working - Stack Overflow
No comments:
Post a Comment