Custom CSS cursor using jQuery css method

Is there a way to use jQuery.css () to create the following cursor style ?:

cursor: url(http://www.google.com/intl/en_ALL/mapfiles/closedhand.cur), default !important; 
+4
source share
2 answers

jQuery does not understand !important , so if you delete it, it will work:

 $('selector').css({ 'cursor': 'url(http://www.google.com/intl/en_ALL/mapfiles/closedhand.cur), default'}); 

Are there any ways around this, why not use a CSS class?

 /* CSS */ .cursor { cursor: url('http://www.google.com/intl/en_ALL/mapfiles/closedhand.cur'), default !important; } 

So you can simply:

 $('selector').addClass('cursor'); 

There are other alternatives: How to apply! important using.css ()?

+6
source

This seems to work for me in fiddle using the code below, but yes, as mentioned above, I removed !important which made it work.

 $('#cursor').css( 'cursor','url(http://www.google.com/intl/en_ALL/mapfiles/closedhand.cur),default' ); 
+1
source

All Articles