Custom CSS cursor using JQuery css method

css, jquery

Solution

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()?

Problem

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; ```

Original source

Related problems