Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I put a semicolon in the href of a Javascript-only link?

Are there any advantages/disadvantages of

<a href="javascript:;" onclick="myFunc()">do myFunc</a>

over

<a href="javascript:" onclick="myFunc()">do myFunc</a>
like image 931
AndreKR Avatar asked Mar 21 '13 18:03

AndreKR


1 Answers

 <a href="javascript:;" onclick="myFunc()">do myFunc</a>- 

      Will kill script execution


  <a href="javascript:" onclick="myFunc()">do myFunc</a>
       Execute Script

For example: http://jsfiddle.net/JZje5/

like image 148
Amit Avatar answered Oct 15 '22 18:10

Amit