Created
January 17, 2014 13:00
-
-
Save caok/8472990 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload | |
必须等待网页中所有的内容加载完毕后(包括图片)才能执行 | |
不能同时编写多个,比如: | |
window.onload = function() { | |
alert("111"); | |
}; | |
window.onload = function() { | |
alert("222"); | |
}; | |
结果只会输出“222” |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready() | |
网页中所有DOM结构绘制完毕后就执行,可能DOM元素关联的东西并没有加载完 | |
能同时编写多个,比如: | |
$(document).ready(function(){ | |
alert("111"); | |
}); | |
$(document).ready(function(){ | |
alert("222"); | |
}); | |
结果两次都输出 | |
$(document).ready(function(){ | |
//.... | |
}); | |
可以简写成: | |
$(function(){ | |
//... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment