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

Posted on 2008-11-04
Last Modified: 2012-05-05
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?
Question by:jdana
    LVL 15

    Accepted Solution

    add style="cursor: pointer;" to your anchor tag styles :)
    LVL 75

    Assisted Solution

    by:Michel Plungjan
    Why not add the href???
    <a href="#"
    onClick="someFunction(); return false">Click</a>

    is much more compatible and gives you the finger for free ;)
    LVL 15

    Expert Comment

    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.

    LVL 75

    Expert Comment

    by:Michel Plungjan

    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

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

    Open in new window


    Author Closing Comment

    style="cursor: pointer;" is perfect.  Thanks.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
    When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now