javascript JQuery(window).load 页面加载后?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11587381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JQuery(window).load after the page loaded?
提问by user
Will JQuery
run the function passed in $(window).load(callback)
, when this listener added after the window.load
event?
当这个监听器在事件之后添加时,会JQuery
运行传入的函数吗?$(window).load(callback)
window.load
回答by Rocket Hazmat
No, $(window).load(function(){})
is only called if it's bound before the event.
不,$(window).load(function(){})
只有在事件之前绑定时才会调用。
On the flip side, $(document).ready(function(){})
(and its shorthand $(function(){})
) willbe triggered (immediately) if they are bound after the event.
在另一面,$(document).ready(function(){})
(和它的简写$(function(){})
)将被触发(立即),如果他们在事件发生后的约束。
回答by Wouter J
No, it won't: http://jsfiddle.net/WouterJ/zMEZA/
不,它不会:http: //jsfiddle.net/WouterJ/zMEZA/
But a $(window).ready
event will: http://jsfiddle.net/WouterJ/zMEZA/1/
但是一个$(window).ready
事件会:http: //jsfiddle.net/WouterJ/zMEZA/1/