Solving development problems  |  About this blog

Archive for the ‘seo’ tag

Prevent link click with JQuery, avoid the javascript:void(0)

It is forbidden to use:

<a href="javascript:void(0);">Some text</a>
Instead of that use JQuery to simulate link and you can put in href attribute whatever you want:

<a id="myLink" href="everything-i-want-to-rewrite" title="link title">Some text</a>

And in JQuery use this:

$("#myLink").click(function(e) {
  //
  //do something
  //

  //Prevent event propagation and click
  e.preventDefault();
});