您可以使用.on()将事件绑定到尚不存在的元素; 但除此之外,我认为你没有太多的解决方案.
你准备做什么?
$(document).on("click", "#futureID", function(){
/* whenever <a id='futureID'>Hello</a> is created,
it will have this functionality */
});
/* Sometime in the future, you add the link */
$("body").append("<a href='index.php' id='futureID'>Hello</a>");
Run Code Online (Sandbox Code Playgroud)
该链接将具有已经连接的上述功能.
| 归档时间: |
|
| 查看次数: |
1703 次 |
| 最近记录: |