jquery中ready()函數(shù)執(zhí)行的時(shí)機(jī)和window的load事件比較
jquery的ready()實(shí)現(xiàn)的是 DOMContentLoaded 事件,DOMContentLoaded與window load事件的區(qū)別
簡(jiǎn)單的說(shuō)ready()是在文檔加載完成就會(huì)觸發(fā),此時(shí)圖片等資源可能還沒(méi)有完全加載, load是在所有資源都加載完成后才會(huì)觸發(fā)
看下ready函數(shù)的代碼就什么都清楚了。下面的代碼加上了注釋?zhuān)?/p>
// Handle when the DOM is ready
ready: function() {
// Make sure that the DOM is not already loaded
if ( !jQuery.isReady ) {
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
if ( !document.body ) {
return setTimeout( jQuery.ready, 13 );
}
// Remember that the DOM is ready
jQuery.isReady = true;
// If there are functions bound, to execute
if ( readyList ) {
// Execute all of them
var fn, i = 0;
while ( (fn = readyList[ i++ ]) ) {
fn.call( document, jQuery );
}
// Reset the list of functions
readyList = null;
}
// Trigger any bound ready events
if ( jQuery.fn.triggerHandler ) {
jQuery( document ).triggerHandler( "ready" );
}
}
},
以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。
- jQuery學(xué)習(xí)筆記 操作jQuery對(duì)象 文檔處理
- Jquery 基礎(chǔ)學(xué)習(xí)筆記之文檔處理
- 詳解Jquery實(shí)現(xiàn)ready和bind事件
- jquery $(document).ready()和window.onload的區(qū)別淺析
- jQuery中ready事件用法實(shí)例
- jQuery.holdReady()方法用法實(shí)例
- jQuery的ready方法詳解
- jquery中的$(document).ready()使用小結(jié)
- Jquery中"$(document).ready(function(){ })"函數(shù)的使用詳解
- JQuery的ready函數(shù)與JS的onload的區(qū)別詳解
- 模擬jQuery中的ready方法及實(shí)現(xiàn)按需加載css,js實(shí)例代碼
- jQuery的文檔處理程序詳解
相關(guān)文章
利用jQuery接受和處理xml數(shù)據(jù)的代碼(.net)
以下使用jQuery+Servlet接受和處理xml數(shù)據(jù),模擬判斷用戶(hù)名是否存在2011-03-03
jQuery在vs2008及js文件中的無(wú)智能提示的解決方法
我通過(guò)下面方法實(shí)現(xiàn)了jQuery在VS2008及js文件中的智能提示的,希望對(duì)朋友們有所幫助。2010-12-12
20款超贊的jQuery插件 Web開(kāi)發(fā)人員必備
jQuery的易擴(kuò)展性吸引了來(lái)自全球的開(kāi)發(fā)者來(lái)共同編寫(xiě)jQuery插件。jQuery插件不僅能夠增強(qiáng)網(wǎng)站的可用性,有效地改善用戶(hù)體驗(yàn),還可以大大減少開(kāi)發(fā)時(shí)間。現(xiàn)在的jQuery插件很多,可以根據(jù)您的項(xiàng)目需要來(lái)選擇。這里為您介紹20款非常不錯(cuò)的插件。2011-02-02
jquery keypress,keyup,onpropertychange鍵盤(pán)事件
項(xiàng)目所需,在試圖用js實(shí)現(xiàn)這樣的功能:文本框失去焦點(diǎn)時(shí),判斷輸入字符串的長(zhǎng)度,以驗(yàn)證是否超出范圍,超出范圍則自動(dòng)截取。2010-06-06
Jquery公告滾動(dòng)+AJAX后臺(tái)得到數(shù)據(jù)
ajax得到值,用JQUERY綁定給對(duì)應(yīng)的UL.利用JQUERY的動(dòng)畫(huà)來(lái)實(shí)現(xiàn)他們的滾動(dòng)公告。2011-04-04
jquery實(shí)現(xiàn)不包含當(dāng)前項(xiàng)的選擇器實(shí)例
這篇文章主要介紹了jquery實(shí)現(xiàn)不包含當(dāng)前項(xiàng)的選擇器,實(shí)例分析了jquery選擇器的使用技巧,需要的朋友可以參考下2015-06-06

