I need a tag that doesn't go anywhere when I click on it but will show the little hand with index finger outstretched like I am hovering over the text teh tag applies to. I googled for a while, but could not find anything related to what I am looking for. I need this because I am writing a file that will execute a javascript function when I click on it, which will display some new information, so I want it to appear to the user that he/she is clicking on a link.

Recommended Answers

All 14 Replies

<A HREF="#">Link Here</A>

?

Thanks for the reply, but I found something even better, and I am a little embarrassed that I forgot I could do this.

<a href="javascript:display_spaces()">Get spaces</a>

Much simpler. Only thing is I usually hate these links cause I always click links with my middle mouse button to open a new tab in firefox lol.

Thanks for the reply, but I found something even better, and I am a little embarrassed that I forgot I could do this.

<a href="javascript:display_spaces()">Get spaces</a>

Much simpler. Only thing is I usually hate these links cause I always click links with my middle mouse button to open a new tab in firefox lol.

Or even simpler and "W3C Correct"

<span style="cursor: hand;">Text with Hand Icon</span>

If you're feeling sassy you could even tie that span to a class and add that to the CSS file to keep your code cleaner and more efficent. Using an anchor when not needed is ghetto!

The last suggestion is the best. An anchor tag with the href set to "#" will navigate to the TOP of the page when clicked, which isn't quite the same thing as "go nowhere".

Similarly, using an empty JavaScript is... well, silly, in my opinion.

So I second IAMMATT's suggestion: just style a normal element, such as span, to display the hand cursor.

However, here's my standard scold: When a user sees their cursor turn to a hand, they expect that clicking will DO SOMETHING, in particular, that they will navigate somewhere.

So, creating an element that gives the hand cursor but that does nothing, violates the User Model, which is very nearly always a bad, bad idea.

EDIT: I re-read your original post. You want a hyperlink that runs a Javascript when clicked, so the <a href="javascript[B]:myFunction();">Run your function</a>[/B] is the proper method for this.

BTW "cursor:hand" only works in IE. The correct W3C standard is actually "cursor:pointer," which will work across all major browsers.

BTW "cursor:hand" only works in IE. The correct W3C standard is actually "cursor:pointer," which will work across all major browsers.

Welcome to the community Johnny but try not to revive 4 year old threads in the future.

Actually, I think it's good that he corrected the answer. It's still a valid question and cursor:pointer is still valid CSS for anyone else who might have the same question in the future :)

Actually, I think it's good that he corrected the answer. It's still a valid question and cursor:pointer is still valid CSS for anyone else who might have the same question in the future :)

My post was also almost an exact quote of the response to my first post as a little throwback (I think it was Narue who responded to me)

I was going to reply in defense of my post but cscgal graciously came to my defense instead. (Thank you, cscgal!) I only posted my comment because I had tried what was suggested up above and it didn't work in Safari. Then I discovered http://www.quirksmode.org/css/cursor.html, where I learned that cursor:hand doesn't work in Firefox either. I thought others who found this thread via a Google search (like I did) would find the information useful.

I am one of those people, thnx for the reply johnny ;p

<span onmouseover="this.style.cursor='pointer';" onmouseout="this.style.cursor='default';">hi</span>

What happens in the span stays in the span.
The onmouseout= doesn't do what you think it is doing, and should be removed.

To see what I mean, try this <span onmouseout="this.style.cursor='wait'">hi</span>

lol, sorry i forgot about that. the cursor thing.. lol not like a background color that doesnt chang eback!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.