Frage

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?

War es hilfreich?

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top