I have a canvas div like this
`<div id="canvas" style="pointer-events:none;">`
I have a button that when pressed removes the style
`<input id="" onclick="qqq()" class="button_text" type="button" name="test" value="test"/>`
function qqq() {
document.getElementById("canvas").removeAttribute("style");
alert("I was ran");
}
Is there a eazy way to make it to change the pointer event from none to null instead of removing the style??? I cant find another way to do it. I tried using disabled=disabled and yes im aware to change onclick to event listener.
4
Answers
when a user checks the box they can use the canvas then they don't check the box they cannot use the canvas this is what worked for me kinda a buggy I had to use '' on one and not the other to get it too work. and even then its pointerEvents and not pointer-events..
on
off
Access the
style
property of the element once you find it, and then alter it to your liking:The best way is to simply remove or toggle (depending on your specific case) a custom utility class like
no-pointer
:Or, instead of
toggle
useclassList.remove("no-pointer")
, you get the idea.Also, don’t use HTML inline
on*
handlers. Use addEventListener instead. JS is supposed to be in one place and that’s the respective tag or file. Not disseminated in HTML.It is not recommended to leave inline styles in the tag unless they are needed, as they have the highest priority. It is a good practice to use css classes with the necessary styles instead.
Therefore, there are two options: