What is the difference between $(window).load(function() {})
and $(document).ready(function() {})
in jQuery?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
The
$(window).load()
is NOT available in jQuery 3.0To get around it, you can use it as an "Event Handler Attachment"
The difference are:
$(document).ready(function() {
is jQuery event that is fired when DOM is loaded, so it’s fired when the document structure is ready.$(window).load()
event is fired after whole content is loaded.window.load will be triggered after all the iframe content is loaded
According to DOM Level 2 Events, the load event is supposed to fire on document, not on window. However, load is implemented on window in all browsers for backwards compatibility.
From jquery prospective - it's just adding
load
/onload
event to window and document. Check this out:window.onload vs document.onload