点击画布元素内的文字 [英] Clicking inside canvas element selects text
问题描述
< canvas> << c $ c< / code>标签。有没有办法阻止这种情况发生?我猜测有一个JavaScript解决方案。解决方案返回 false
in一个事件停止标准事件的发生:
pre $ document.getElementById('canvas')。onmousedown = function(){
返回false;
};
编辑:我发现文本选择是在 I have a canvas element in my HTML document. When I click inside of the canvas multiple times, it selects part of my Returning Edit: I just found out that text selection is done before 这篇关于点击画布元素内的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! onclick code>被触发,更好的选择是
onmousedown
。 <h1>
element's text, which is before the <canvas>
tag. Is there a way to stop this from happening? I am guessing there is a JavaScript solution.false
in an event stops the standard event from happening:document.getElementById('canvas').onmousedown = function(){
return false;
};
onclick
is fired, a better option is onmousedown
.