change cursor to finger pointer

前端 未结 10 2088
孤街浪徒
孤街浪徒 2021-01-30 15:17

I have this a and I don\'t know that I need to insert into the \"onmouseover\" so that the cursor will change to finger pointer like a regular link:



        
相关标签:
10条回答
  • 2021-01-30 15:47

    Solution via pure CSS as mentioned in answer marked as the best is not suitable for this situation.

    The example in this topic does not have normal static href attribute, it is calling of JS only, so it will not do anything without JS.

    So it is good to switch on pointer with JS only. So, solution

    onMouseOver="this.style.cursor='pointer'"
    

    as mentioned above (but I can not comment there) is the best one in this case. (But yes, generaly, for normal links not demanding JS, it is better to work with pure CSS without JS.)

    0 讨论(0)
  • 2021-01-30 15:47

    div{cursor: pointer; color:blue}
    
    p{cursor: text; color:red;}
    <div> im Pointer  cursor </div> 
    <p> im Txst cursor </p> 

    0 讨论(0)
  • 2021-01-30 15:47
     <! ––  add this code in your class called menu_links -->
    <style> 
    .menu_links{
    cursor: pointer;
    }
    </style>
    

    In the above code [cursor:pointer] is used to access the hand like cursor that appears when you hover over a link.

    And if you use [cursor: default] it will show the usual arrow cursor that appears.

    To know more about cursors and their appearance click the below link: https://www.w3schools.com/cssref/pr_class_cursor.asp

    0 讨论(0)
  • 2021-01-30 15:48

    in css write

    a.menu_links:hover{ cursor:pointer}
    
    0 讨论(0)
  • 2021-01-30 15:54

    You can do this in CSS:

    a.menu_links {
        cursor: pointer;
    }
    

    This is actually the default behavior for links. You must have either somehow overridden it elsewhere in your CSS, or there's no href attribute in there (it's missing from your example).

    0 讨论(0)
  • 2021-01-30 15:57

    I think the "best answer" above, albeit programmatically accurate, does not actually answer the question posed. the question asks how to change the pointer in the mouseover event. I see posts about how one may have an error somewhere is not answering the question. In the accepted answer, the mouseover event is blank (onmouseover="") and the style option, instead, is included. Baffling why this was done.

    There may be nothing wrong with the inquirer's link. consider the following html:

    <a id=test_link onclick="alert('kinda neat);">Click ME!</a>
    

    When a user mouse's over this link, the pointer will not change to a hand...instead, the pointer will behave like it's hovering over normal text. One might not want this...and so, the mouse pointer needs to be told to change.

    the answer being sought for is this (which was posted by another):

    <a id=test_link onclick="alert('Nice!');"
           onmouseover="this.style.cursor='pointer';">Click ME!</a>
    

    However, this is ... a nightmare if you have lots of these, or use this kind of thing all over the place and decide to make some kind of a change or run into a bug. better to make a CSS class for it:

    a.lendhand {
      cursor: pointer;
    }
    

    then:

    <a class=lendhand onclick="alert('hand is lent!');">Click ME!</a>
    

    there are many other ways which would be, arguably, better than this method. DIVs, BUTTONs, IMGs, etc might prove more useful. I see no harm in using <a>...</a>, though.

    jarett.

    0 讨论(0)
提交回复
热议问题