I've been trying to use something in JS like:
getElementById("dartboard").style.pointer-events = "none";
However, this does not work and the = has a red underline. Any ideas?
Attribute names need to written in camelCase like so:
pointer-events
=> pointerEvents
<svg id="dartboard" width="100px" height="100px" viewBox="0 0 100 100"> <circle cx="50%" cy="50%" r="25%" fill="red" stroke="green"/> </svg> <script> let dartboard = document.getElementById("dartboard"); dartboard.addEventListener('click', function(e) { alert('click'); }) dartboard.style.strokeWidth = 10; dartboard.style.pointerEvents = "none"; </script>
You can change the css properties from javascript, as it is described here: https://www.w3schools.com/js/js_htmldom_css.asp
var obj = document.getElementById("container");
obj.style.pointer-events = "none";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.