Difference between DOMContentLoaded and load events

后端 未结 6 1898
执笔经年
执笔经年 2020-11-22 08:43

What is the difference between DOMContentLoaded and load events?

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 08:57

    DOMContentLoaded==window.onDomReady()

    Load==window.onLoad()

    A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $(document).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside $(window).load(function() { ... }) will run once the entire page (images or iframes), not just the DOM, is ready.

    See: Using JQuery Core's document-ready documentation.

提交回复
热议问题