Вопрос

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?

Это было полезно?

Другие советы

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top