jQuery HTML Element How to - Custom CSS cursor using JQuery css method








Question

We would like to know how to custom CSS cursor using JQuery css method.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<style type='text/css'>
#cursor {
  width: 200px;
  height: 200px;
  border: 1px solid black;
}<!--from w w  w.ja  v a 2s . c  om-->
</style>
<script type='text/javascript'>
$(window).load(function(){
    $('#cursor').css(        
        'cursor','url(http://www.java2s.com/style/download.png),default'
    );
});
</script>
</head>
<body>
  <div id="cursor"></div>
</body>
</html>

The code above is rendered as follows: