Answers for "prevent default onclick javascript"

0

prevent from going to a function html click

$("#clickable a").click(function(e) {
   // Do something
   e.stopPropagation();
});
Posted by: Guest on July-03-2020
0

prevent onclick event javascript

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

//Using JS
const clickable = true;

document.getElementById("foo").onclick = () => {
    if (clickable) {
        //...your code
    }
}
Posted by: Guest on April-13-2022

Code answers related to "prevent default onclick javascript"

Browse Popular Code Answers by Language