Latest web development tutorials

jQuery load () method

jQuery Event Methods jQuery Event Methods

Examples

When the image is fully loaded alert text:

$("img").load(function(){
    alert("图片已载入");
});

try it"

Definition and Usage

load () method in jQuery version 1.8 is obsolete .

load () method to add an event handler to the load event.

When the specified elements have been loaded, load event occurs.

This event applies to any element with a URL (such as images, scripts, frames, inline frame), and window object.

Depending on the browser (Firefox and IE), if the image has been cached, it may not trigger the load event.

Note: there is a jQuery called load () of AJAX methods. Depending on the parameters to determine which method call.


grammar

$(selector).load(function)

参数 描述
function 必需。规定当指定元素加载完成时运行的函数。


Examples

More examples

Display some text when the image is fully loaded
When the image is fully loaded how to change the text <div> element.

When the page is fully loaded Alert Text
When the window objects (including images) is fully loaded when the alarm text.


jQuery Event Methods jQuery Event Methods