Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the cursor on a hold down?

Tags:

html

jquery

So i want to change the cursor from

#sideBar ul li .template{
 cursor:pointer;
}

to maybe cursor:move; when the user is dragging...is there something i can use in jQuery or html to make this happen you hold down the mouse button

like image 428
Matt Elhotiby Avatar asked Nov 02 '10 21:11

Matt Elhotiby


People also ask

How do I change my cursor to normal?

Step 1: In the Windows search box, search for "ease of access" and select Ease of access mouse settings from the resulting list. Step 2: In the left-side menu, select Mouse pointer. Step 3: Under Change pointer size, you can adjust the bar to a size that works best for you.


1 Answers

Instead of changing the css in your javascript code, keep it to just changing one class, which will update your element with as many different things as you want. I added a :hover pseudo-class because I'm not sure if cursor works without it.

Also, live works for any element added in the future and bind does not.

Css:

#sideBar ul li .template{
 cursor:pointer;
}

#sideBar ul li .template.mouseDown:hover{
 cursor:auto; /* or whatever cursor */
}

Javascript:

$("#sideBar ul li .template").live("mousedown", function () {
    $(this).addClass("mouseDown");
}).live("mouseup", function () {
    $(this).removeClass("mouseDown");
});
like image 180
JustcallmeDrago Avatar answered Sep 30 '22 21:09

JustcallmeDrago