How to unleash all events inside a specific div

I have a parent div, say with id = "to-remove"

This div has several child divs and each div div can also have several divs and each of them can have href and / or onclick events.

Is there a way to remove all of these events from this parent div using jquery ..?

+8
javascript jquery
source share
2 answers

Have you tried .unbind() :

 $('#to-remove *').unbind('click'); // just for click events $('#to-remove *').unbind(); // for all events 

And as for jQuery 1.7, .on() and .off() preferable to attach and remove event handlers on the elements. (from the .unbind() documentation) So, if you use jQuery> 1.7.x, then this would be better:

 $('#to-remove *').off(); 
+23
source share

Try:

 $ ('# to-remove *'). unbind ();
 // or you could assign some class and do
 $ ('. some-class'). unbind ();
+3
source share

All Articles