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?

Était-ce utile?

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)"?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top