I would like to dynamically add a button control to a table using jQuery and attach a click event handler. I tried the following, without success:
$(\"#myBut
Your problem is that you're converting the button into an HTML snippet when you add it to the table, but that snippet is not the same object as the one that has the click handler on it.
$("#myButton").click(function () {
var test = $('').click(function () {
alert('hi');
});
$("#nodeAttributeHeader").css('display', 'table-row'); // NB: changed
var tr = $('').insertBefore('#addNodeTable tr:last');
var td = $('').append(test).appendTo(tr);
});
- 热议问题