jQuery unload()

jQuery unload()

0 260

  • This jQuery function is worked when the unload event occurs or it binds an event handler with the element when an unload event occurs.
  • An unload event happens when the user navigates away from the page or a specific HTML DOM element is unloaded to the page.
  • An unload event comes into existence when,

1 A link that leads to leaving the page clicked by the user.

2 User use either forward or backward button.

3 The current window closed by the user.

4 User reloads the page.

5 A new address is entered by the user into the address bar.

Related Topic:

jQuery hover
jQuery load

jQuery unload


This method is specifically used for windows related actions and it may give different results with different browsers.


$(selector). unload(function);

Parameter description:

  • function: It represents the function to run when the unloading of the specific page is done.


<title>jQuery Example</title>
<script type = "text/javascript"
alert("Thanks for visiting!");

<h2>jQuery unload() method Example</h2>
<p>An alert box is open when you <a href="https://www.codingtag.com/">click here!</a></p>



Leave a Reply

    Waiting for your comments