Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a link that goes nowhere?

Tags:

html

hyperlink

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.

like image 911
Ankur Avatar asked Dec 02 '09 05:12

Ankur


People also ask

How do you make a link that does nothing?

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.

How do you make a dead link in HTML?

Replace the href attribute value with a #, also known as a hash symbol, to create a dead link.

How do you make clickable links?

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.


2 Answers

Will add to the browser history:

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

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

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

like image 124
leepowers Avatar answered Sep 20 '22 18:09

leepowers


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> 
like image 27
jheddings Avatar answered Sep 20 '22 18:09

jheddings