Canvas How to - Hide mouse on canvas








Question

We would like to know how to hide mouse on canvas.

Answer


<!-- w w w  . j ava  2 s .co m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
<style type='text/css'>
    canvas{border:1px solid red;}
</style>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
     $("#theCanvas").click(function () {
         alert("You clicked the canvas with an invisible mouse!");
         $("#theCanvas").css("cursor", "none");
     });
});//]]>  
</script>
</head>
<body>
   <p">Click the red canvas and I'll hide the cursor when you are over me</p>
   <canvas id="theCanvas"></canvas>
</body>
</html>

The code above is rendered as follows: