jQuery Style How to - Use custom image as Cursor








Question

We would like to know how to use custom image as Cursor.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.1.js'></script>
<style type='text/css'>
div {<!--from  ww w. j  a  v a2 s.  c  om-->
  width: 500px;
  height: 500px;
  background-color: #F00;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $("div").css('cursor','url("http://www.java2s.com/style/download.png"),auto');
});
</script>
</head>
<body>
  <div></div>
</body>
</html>

The code above is rendered as follows: