我在动态添加的 html 元素上调用 JavaScript/jQuery 1.9.1 方法时遇到了一些麻烦。
这是我的 JS 代码:
$(".download").live("click", function() {
var buttonId = $(this).attr("id");
alert(buttonId);
});
我的动态 HTML 代码:
var html = "";
for(var i = 0; i <daten.length; i++) {
html += "<input id='" + daten[i].pfad + "' class='download' type='image' width='25px' height='25px' src='/download.png'/>";
}
$("#table").append(html);
我没有收到错误消息,但是该方法除了没有调用之外,还有什么不正确的?