需要这样的东西(以便将来加载 html 到页面!):
$(document).on('ready', 'a', function(){ $(this).after('it works'); });
这不起作用(需要类似的事件,例如“加载”或“准备”在元素添加到页面后触发)。例如另一个事件:
$(document).on('mouseover', 'a', function(){ $(this).after('it works'); });
工作正常。有什么建议吗?
最佳答案
这可能是因为这些元素不会触发 onload
事件。 document
的 load
事件在所有元素加载后触发,因此您可以尝试使用该事件。
$(document).on('DOMNodeInserted', 'a', function(){ $(this).after('it works'); });
关于javascript - 在加载后将字符串附加到 future 元素(jquery),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12036489/