Update HTML5 canvas rectangle on hover?

后端 未结 8 776
暗喜
暗喜 2020-12-03 01:57

I\'ve got some code which draws a rectangle on a canvas, but I want that rectangle to change color when I hover the mouse over it.

The problem is after I\'ve drawn t

8条回答
  •  孤街浪徒
    2020-12-03 02:19

    You could use canvas.addEventListener

    var canvas = document.getElementById('canvas0');
    canvas.addEventListener('mouseover', function() { /*your code*/ }, false);
    

    It worked on google chrome

提交回复
热议问题