且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Dom onload和jQuery document ready的区别

更新时间:2022-09-06 07:47:50

使用如下代码进行测试:

<html>
<script src="jquery_1.7.1.js">
</script>
<script>
$(document).ready(start());
function start() {
 console.log("start here");
 var main = $("#main");
 console.log("length: " + main.length);
 var another = document.getElementById("main");
 var oHeader = document.getElementById("header");
 $("#main").queue('test', function() { console.log("1");});
 $("#main").queue('test', function() { console.log("2");});
 $("#main").queue('test', function() { console.log("3");});
 $("#main").dequeue('test');
 $("#main").dequeue('test');
 $("#main").dequeue('test');
}
</script>
<body id = "main" οnlοad="start();">
<h1 id = "header">hello</h1>
</body>
</html>

首先是jQuery的document.ready 事件触发:Dom onload和jQuery document ready的区别Dom onload和jQuery document ready的区别