Reputation: 53876
Reading this question : What does "javascript:void(0)" mean? I can understand why <a href="javascript:void(0)"
is used - in order to prevent a page redirection.
I have come across this code :
<a id="myId" href="javascript:void()"
onclick="removePopup()">Close</a>
The operator void
does not take any parameter in this case. Is this a bug ?
Upvotes: 0
Views: 305
Reputation: 33143
Yes, it's a bug. The browser will throw a syntax error when the link is clicked, unless the removePopup()
function stops the default action. (If the function does that, it might explain why the developer didn't notice it.)
> void()
SyntaxError: Unexpected token )
Upvotes: 2