JavaScript how to change mouse cursor to an image?

JDS picture JDS · Jun 3, 2012 · Viewed 51k times · Source

I've seen examples where you can change it to preset images that your operating system has; example:

$('body').css('cursor', 'wait'); 

But how about my own /img/my_image.png?

Thanks for any help.

Answer

malangi picture malangi · Jun 3, 2012

You can, by specifying a url to it in CSS:

div {
    cursor: url(smiley.gif), url(myBall.cur), auto;
}

See http://www.w3schools.com/cssref/pr_class_cursor.asp