对于javascript addeventlistener加载 , Google的热门搜索是基于jQuery的,因此与我无关。我想要一个干净的参考书,以了解如何将事件最好地绑定到原始javascript中的文档就绪状态。
how to best bind an event to a document's ready state
That would probably be...
document.addEventListener("DOMContentLoaded", function() { });
MDN's Reference for Events show the load event being the desired trigger. This post explains not to bind to the document
node, rather to bind to the window
node.
window.addEventListener('load', function(){ console.log('document ready!'); });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.