Date: 2011feb3
Platform: web
Q. javaScript: How do I make a link that does nothing?
A. Use void(0) like this:
<a href='javascript:void(0)'>a link that does nothing</a>
This will look like regular link but will not reload the current page or
anything. (Unlike href=#)
Now, you can use other techniques to make it do something useful.
Regular javaScript:
<a href='javascript:void(0)' onclick='doStuff()'>a link that does nothing</a>
With jQuery:
<a id=mylink href='javascript:void(0)'>a link that does nothing</a>
$('#mylink').click(doStuff);
// or
$('#mylink').click(function(){
// do things
});
Using href='#' has been suggested. It does very little but it does append # to the
current URL. So I prefer the above way.