It is also used to prevent unwanted redirecting of the page.
In the following example, we are defining two links. In the first link, we are using the void keyword. When the corresponding link gets clicked, it will do nothing because of the void(0).
When we click on the second link, it will display an alert dialog box.Test it Now
On clicking the first link, nothing will happen. When the user clicks the second link, the output will be -
Now, in the next example, we will see how to prevent redirecting of the webpage.
On double-clicking the specified link, the output will be -