Is there any way to disable and enable an existing event on an object?
Example, I have an event in an element <img onclick="foo();">
On this same page, there is an action where, while running, you need to prevent the user from running events from other objects.
To do this, when running such an event, all others are disabled.
The problem is that I can not find anything in the JQuery documentation regarding this.
The only way is to delete the event from the other objects and when you need to activate them again you have to do the creation of these events again.
That way it works fine, however, I think there could be something more economical like a simple "enable", "disable".
I'm using Jquery, however, if there is a way to resolve it directly through JavaScript, it's obviously quite valid.
I thought that disabling the object would work, but it does not work. Even with the object set to "disabled", events persist normally.
Example:
<img id="bar" onclick="foo();">
/*
Tentei com attr() e prop(). Ambos não surtem efeito.
*/
//$('#bar').prop('disabled',true);
$('#bar').attr('disabled',true);
When you click on the object, it still triggers the event even though it is disabled.
Is this due to the type of the object or some header? In HTML I'm using strict DTD.
Another way to solve it would be to open a modal in front of the entire screen, preventing access to the bottom layer, but I want to avoid this for now.