Skip to content Skip to sidebar Skip to footer

How Do I Disable All The Onclick Events On A Page

Hi want to disable all onclick events on a page i write this: window.onclick = anyfunction; document.onclick=anyfunction; function anyfunction() {}; That's work but if page contai

Solution 1:

$("*").unbind("click"); // Removes all click handlers added by javascript from every element
$("[onclick]").removeAttr("onclick"); // Finds all elements with an 'onclick' attribute, and removes that attribute

Solution 2:

This css may help you in a better way.

functiondisableEvents()
{
$('#divname').css('pointer-events','none');
}

call this function where ever and whenever you would like to stop the click events on your page. This will work.

Solution 3:

you could also try

$('*').click(function(e){e.preventDefault();});

also see - How to prevent onclick statements from being executed?

and - Prevent onclick action with jQuery

Post a Comment for "How Do I Disable All The Onclick Events On A Page"