0

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?

srgg6701
  • 1,878
  • 6
  • 23
  • 37

2 Answers2

1

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

Community
  • 1
  • 1
thefourtheye
  • 233,700
  • 52
  • 457
  • 497
1

You should use javascript:void(0)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void

Frank
  • 530
  • 5
  • 15