Update HTML5 canvas rectangle on hover



To update HTML5 canvas rectangle on hover, try to run the following code:

var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); context.rect(20,20,150,100); context.stroke(); $(canvas).hover(function(e){    context.fillStyle = blue;    context.fill(); });
Updated on: 2020-01-29T08:09:58+05:30

637 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements