Instead of changing css in your javascript code, save it by simply changing one class that will update your element as many times as you want. I added the: hover pseudo-class because I'm not sure what cursorworks without it.
In addition, live works for any element added in the future, but the binding does not.
Css:
#sideBar ul li .template{
cursor:pointer;
}
#sideBar ul li .template.mouseDown:hover{
cursor:auto;
}
JavaScript:
$("#sideBar ul li .template").live("mousedown", function () {
$(this).addClass("mouseDown");
}).live("mouseup", function () {
$(this).removeClass("mouseDown");
});
source
share