How do I make a link that goes nowhere?

Is it possible to make a link that does nothing?

I want the item to be a link so I get the cursor to change on mouseover, but I don't want the link to actually go anywhere as it actually triggers the showing of a div with extra functionality on the same page.


Solution 1:

Will add to the browser history:

<a href="#"></a>

Won't add to the browser history (preferred method):

<a href="javascript:;"></a>

Solution 2:

Instead, you could use a <span> and set the cursor style:

<span id="node42" class="node-link">My Text</span>

And specify the cursor in your stylesheet:

.node-link { cursor: pointer; }

This would also allow you to attach to the node for your actions later (show here using Prototype):

<script type="text/javascript">
    $('node42').observe('click', function(event) {
      alert('my click handler');
    });
</script>

Solution 3:

In my opinion, the most complete hack free solution is:

<a href="" onclick="return false;">do absolutely nothing</a>

Solution 4:

Just add the style cursor:pointer to the element:

<a id="clickme">Click Me</a>

CSS:

#clickme { cursor: pointer }

Or (heaven forbid) in-line:

<a style="cursor:pointer">Click Me</a>