jquery是怎么实现:页面加载完毕,而图片未加载?

2025-03-03 21:15:35
推荐回答(2个)
回答1:

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" );
}
}
}

上面代码可以看出,是每隔0.013秒检查一次document.body是否为真来实现的。

回答2:

根据html的原理,body载入完毕的时候,只是载入的各个标签,图片也是载入img标签。图片是异步加载的。