How to set cursor image via jQuery?

Enabling the web application I have a download event. If the browser is downloading data from the server, I want the cursor to change to gif, which shows the clock. How to change the appearance of the cursor. I just found this on the blog, citing the apperance of the cursor:

$(this).css('cursor','move'); 

I want to upload an image instead.

+7
source share
2 answers

Try as follows:

 $(this).css( 'cursor', 'url(cursor.png), auto' ); 

Here is the JSFiddle: http://jsfiddle.net/fv3Bk/1/
The auto parameter specifies which type of cursor to use if the cursor image is not found. (See here for more types of cursors; here is an example with another)

+16
source

If you want the cursor to be the cursor of your choice, you can use the css cursor property as above, but with the URL value:

 $(this).css('cursor', 'url(/path/to/image),auto'); 

or to everyone inside the body:

 $('body').css('cursor', 'url(/path/to/image),auto'); 

As far as I know, this will not work in Opera.

+8
source

All Articles