Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
80
rated 0 times [  84] [ 4]  / answers: 1 / hits: 120381  / 11 Years ago, sat, may 11, 2013, 12:00:00

I am trying to set pointer-events: none for a div through JavaScript, however the property is not being applied.



I have tried:



document.getElementById(div).setAttribute(pointer-events, none);


And:



document.getElementById(div).style.pointer-events = none;


But neither worked, any ideas?


More From » css

 Answers
36

Your first attempt failed because it was a CSS property and not an attribute (part of the style attribute).


Your second attempt failed because for some off reason, when making this API casing-like-this gets converted to camelCasingLikeThis . This is likely because the folks who built JavaScript and the folks who built CSS weren't very well coordinated.


The following should work:


document.getElementById("div").style.pointerEvents = "none";

[#78298] Thursday, May 9, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
allans

Total Points: 336
Total Questions: 120
Total Answers: 119

Location: Peru
Member since Mon, Jun 6, 2022
2 Years ago
allans questions
;