jQuery > Events

Load event in jQuery

How to attach load event to a html element in jQuery?

To attach load method to an html element, load() method can be used.

  <img id="imgLoad" src="http://www.itfunda.com/Images/itfunda.gif" />

    $("#imgLoad").load(function () {
        alert("ITFunda.Com Logo loaded");

In the above code when the image will be loaded completely then user will be alerted with "ITFunda.Com logo loaded". In case any problem occurs while loading the image then no alert will be shown to the user. If we want to get notification if image couldn't get loaded, we can use .error() method.

 Views: 5162 | Post Order: 76

Write for us

Hosting Recommendations