Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
524 views
in Technique[技术] by (71.8m points)

javascript - window.onload与$(document).ready()(window.onload vs $(document).ready())

JavaScript的window.onload和jQuery的$(document).ready()方法有什么区别?

  ask by Vaibhav Jain translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (eg images) also has been loaded.(ready事件在HTML文档已加载之后发生,而onload事件在稍后又加载了所有内容(例如图像)时发生。)

The onload event is a standard event in the DOM, while the ready event is specific to jQuery.(onload事件是DOM中的标准事件,而ready事件特定于jQuery。) The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds functionality to the elements in the page doesn't have to wait for all content to load.(ready事件的目的是,它应该在文档加载后尽早发生,从而使向页面中的元素添加功能的代码不必等待所有内容加载。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...