Want the hyperlink pointer finger to appear on anchor text without the href attribute.

I have anchor text that calls JavaScript when clicked.  Because the anchor lacks an href attribute, the anchor text doesn't show the characteristic hyperlink behavior (underlined text, and the pointer finger when the cursor is over the text).  I don't need the underline, but I would like to see the pointer finger.  How do I accomplish this?
jdanaAsked:
Who is Participating?
 
Tomarse111Connect With a Mentor Commented:
add style="cursor: pointer;" to your anchor tag styles :)
0
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
Why not add the href???
<a href="#"
onClick="someFunction(); return false">Click</a>

is much more compatible and gives you the finger for free ;)
0
 
Tomarse111Commented:
if your going to add the href then shouldn't you add something along the lines of:

<a href="javascript:void(0)" onclick="someFunction();">

instead of the #? This would get around the the whole page bouncing to the top of the window scenario.

:-)
0
 
Michel PlungjanIT ExpertCommented:
No.

The return false on the onClick will stop that and the # only loaded if JS is turned off. IF js is turned off or not available, then javascript:void(0) will give a nasty http error


the BETTER solutions are


<script>
document.write('<a href="#" onClick="someFunction(); return false">Click</a>')
</script>
 
or 
 
<a href="please_turn_on_javascript_for_this_link_to_work.html"
onClick="someFunction(); return false">Click</a>

Open in new window

0
 
jdanaAuthor Commented:
style="cursor: pointer;" is perfect.  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.