欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery中ready()函數(shù)執(zhí)行的時(shí)機(jī)和window的load事件比較

 更新時(shí)間:2015年06月22日 10:30:57   投稿:hebedich  
這篇文章主要介紹了jquery中ready()函數(shù)執(zhí)行的時(shí)機(jī)和window的load事件比較的相關(guān)資料,需要的朋友可以參考下

jquery的ready()實(shí)現(xiàn)的是 DOMContentLoaded 事件,DOMContentLoaded與window load事件的區(qū)別

簡(jiǎn)單的說ready()是在文檔加載完成就會(huì)觸發(fā),此時(shí)圖片等資源可能還沒有完全加載, load是在所有資源都加載完成后才會(huì)觸發(fā)

看下ready函數(shù)的代碼就什么都清楚了。下面的代碼加上了注釋:

// 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)容了,希望大家能夠喜歡。

相關(guān)文章

最新評(píng)論