如何清除HTML5画布上的图表,以防止触发悬停事件?
要清除画布上的图表,请删除5ba626b379994d53f7acf72a64f9b697元素,然后将一个新的5ba626b379994d53f7acf72a64f9b697元素附加到父容器中,如下所示的代码:
var resetCanvas = function(){
$('#results-graph').remove();
$('#graph-container').append('<canvas id = results-graph><canvas>');
canvas = document.querySelector('#results-graph');
ct = canvas.getContext('2d');
ct.canvas.width = $('#graph').width(); // here we are resizing the new canvas element to parent width
ct.canvas.height = $('#graph').height(); // here we are resizing the new canvas element to parent height
var a = canvas.width/2;
var b = canvas.height/2;
ct.font = '12pt Calibri';
ct.textAlign = 'Align Left';
ct.fillText('left aligned text on the canvas', a, b);
};
以上就是如何清除HTML5画布上的图表,以防止触发悬停事件?的详细内容,更多请关注双恒网络其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。



