Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 558
shibly Avatar asked Oct 17 '22 14:10

shibly


People also ask

How do I change the cursor type in CSS?

You can simply use the CSS cursor property with the value pointer to change the cursor into a hand pointer while hover over any element and not just hyperlink. In the following example when you place the cursor over the list item, it will change into a hand pointer instead of the default text selection cursor.

How do I change my custom cursor back to normal?

Step 1: Click on the Search box located in the taskbar. Step 2: Type in "mouse." Step 3: Select Change your mouse settings from the resulting list of options to open the primary mouse settings menu. Step 4: Select Additional mouse options.

How will you change the pointer icon when it goes over an a tag?

The default cursor for a hyperlink is "pointer". To change it, you need to specify the cursor type for your <a> element with the CSS :hover selector.

How do I change the cursors on my mouse cursor?

Click “Mouse” form the pane on the left, scroll through the options until you see”Additional mouse options”, and click on it. Click the tab labeled “Pointers”. Now, from the list of cursors under the Customise section, click one that you want to change, and then click “Browse”.

How do I change the shape of my mouse pointers?

Nevertheless, here are a few steps you can try: Click on the Start button. Open the Control Panel . Click on Mouse . Select the Pointers tab. If you want to the look of all your pointers, click on Scheme and select a new mouse pointer scheme. If you want to change the design of a single pointer, click on a pointer below the Customize section.

How to turn a mouse pointer into a hand pointer?

But if you want to have a hand pointer for all of your list items, just set the style for the <li> element. Now let’s see an example of changing a mouse pointer into a hand pointer by using the "pointer" value of the cursor property.

How do I change the cursor type for a hyperlink?

The default cursor for a hyperlink is "pointer". To change it, you need to specify the cursor type for your <a> element with the CSS :hover selector. In our example, we style only the "link" class. Example of changing the “pointer” to “default”: ¶


2 Answers

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:

<div style="cursor: pointer">

</div>

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');
like image 246
Devin Burke Avatar answered Oct 19 '22 03:10

Devin Burke


If you want to do this in jQuery instead of CSS, you basically follow the same process.

Assuming you have some <div id="target"></div>, you can use the following code:

$("#target").hover(function() {
    $(this).css('cursor','pointer');
}, function() {
    $(this).css('cursor','auto');
});

and that should do it.

like image 24
Ryan Atallah Avatar answered Oct 19 '22 04:10

Ryan Atallah