Javascript examples for jQuery Method and Property:load
The load() method was deprecated in jQuery version 1.8 and removed in version 3.0.
The load() method sets event handler to the load event for elements associated with a URL (image, script, frame, iframe), and the window object.
The load event may not trigger if the image is cached.
$(selector).load(function);
Parameter | Require | Description |
---|---|---|
function | Required. | function to run when the specified element is done loading |
The following code shows how to Alert a text when an image is fully loaded:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("img").load(function(){ $("div").text("Image loaded"); });//from w w w .j a v a2 s . c o m }); </script> </head> <body> <img src="http://java2s.com/resources/a.png" alt="message" width="304" height="236"> <div>Image is currently loading.</div> </body> </html>