You should use javascript:void(0)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void
Question
I have noticed that the assignment "javascript:void()" within the link:
<a href="javascript:void()" id="link_id">My link</a>
is caused an error in Chrome Dev console like this:
Uncaught SyntaxError: Unexpected token )
But why? Is this code is incorrect? If it is correct how to avoid such an ugly issue?
La solution
You should use javascript:void(0)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void
Autres conseils
You have to use with 0
like this
<a href="javascript:void(0)" id="link_id">My link</a>
For more information about this, please go through the excellent answers in Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?