我在我的应用程序中使用这段代码:
document.getElementById("inventory_box").innerHTML = "<img src='./img/rock.gif' id='test' />";
#inventory_box
元素已经存在,所以它只是将 IMG
喷出到 #inventory_box
中。
我想要的是能够点击这个出现的 IMG
id name test
,
但不会像这样工作:
$("#test").click(function() {
// Run this
});
最佳答案
关于javascript - jQuery 函数在 JS innerHTML 属性之后不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19224085/