Change the mouse cursor on mouse over to anchor-like style

后端 未结 5 1041
半阙折子戏
半阙折子戏 2021-01-30 03:43

If I hover the mouse over a div the mouse cursor will be changed to the cursor like that in HTML anchor.

How can I do this? Do I need Javascript or it\'s po

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-30 04:12

    Assuming your div has an id="myDiv", add the following to your CSS. The cursor: pointer specifies that the cursor should be the same hand icon that is use for anchors (hyperlinks):

    CSS to Add

    #myDiv
    {
        cursor: pointer;
    }
    

    You can simply add the cursor style to your div's HTML like this:

    EDIT:

    If you are determined to use jQuery for this, then add the following line to your $(document).ready() or body onload: (replace myClass with whatever class all of your divs share)

    $('.myClass').css('cursor', 'pointer');
    

提交回复
热议问题