4

Is there a way I can use JQuery's .css() method to give the following cursor style?:

cursor: url(http://www.google.com/intl/en_ALL/mapfiles/closedhand.cur), default !important;
Thomas
  • 157
  • 1
  • 8

2 Answers2

6

jQuery doesn't understand the !important, so if you remove that it'll work:

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

There are ways to get around it, 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 just:

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

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

Community
  • 1
  • 1
Amy
  • 7,388
  • 2
  • 20
  • 31
1

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

$('#cursor').css(        
    'cursor','url(http://www.google.com/intl/en_ALL/mapfiles/closedhand.cur),default'
);
dev
  • 3,969
  • 3
  • 24
  • 36