Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

prevent onclick event javascript

// Using CSS (prefered)
#foo {
    pointer-events: none;
}

//Using JS
const clickable = true;

document.getElementById("foo").onclick = () => {
    if (clickable) {
        //...your code
    }
}
 
PREVIOUS NEXT
Tagged: #prevent #onclick #event #javascript
ADD COMMENT
Topic
Name
1+8 =