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.
To make an anchor tag refer to nothing, use “javascript: void(0)”. The following link does nothing because the expression "0" has no effect in JavaScript. Here the expression "0" is evaluated, but it is not loaded back into the current document.
Replace the href attribute value with a #, also known as a hash symbol, to create a dead link.
Create a hyperlink to a location on the webSelect the text or picture that you want to display as a hyperlink. Press Ctrl+K. You can also right-click the text or picture and click Link on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box.
Will add to the browser history:
<a href="#"></a>
Won't add to the browser history (preferred method):
<a href="javascript:;"></a>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With