- 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.
This method is specifically used for windows related actions and it may give different results with different browsers.
- function: It represents the function to run when the unloading of the specific page is done.
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>