Question Detail

What does “javascript:void(0)” mean?

4 years ago Views 1132 Visit Post Reply

<a href="javascript:void(0)" id="loginlink">login</a>

I've seen such hrefs many times, but I don't know what exactly that means.


Thread Reply

Anonymous

- 4 years ago

JavaScript:void(0);

Above mentioned statement is a JavaScript query. Which want to return nothing, so generally this code in html page where is a anchor tag which don't want to anywhere and don't want to refresh.

Maine task of javascrJav:void(0);. Is for keep webpage as it is don't want to refresh.

Anonymous

- 4 years ago

An explanation is provided here: void operator.

The reason you’d want to do this with the href of a link is that normally, a javascript: URL will redirect the browser to a plain text version of the result of evaluating that JavaScript. But if the result is undefined, then the browser stays on the same page. void(0) is just a short and simple script that evaluates to undefined.