href javascript ; void 0
The void operator is often used to obtain the undefined
primitive value.
<a href="javascript:void(0);">
Click Me
</a>
In this case, it is used to avoid #
in the URI bar.
The hrefs
value will be undefined
. Hence, when user clicks on the Click Me
link, the URI will remain the same in the address bar.
Alternatives:
<a href="#" onclick="return false;">
Click Me
</a>
<a href="#" onmousedown="return false;">
Click Me
</a>
The return false prevents the page from being navigated and unwanted scrolling of a window.