Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
10
rated 0 times [  14] [ 4]  / answers: 1 / hits: 40006  / 12 Years ago, wed, december 19, 2012, 12:00:00

I have a div element with several elements inside it like buttons and so forth which have event handlers attached to them. I know its possible to go:



$(#button1).off()


To remove the handler for a button but I would like to do something like this if possible:



$(#div1).removeChildHandlers();


Is there a native function in JQuery to do this or would I have to loop them all the elements and remove 1 by 1?


More From » jquery

 Answers
21

jQuery will do the looping for you for just the direct children:



$(#div1).children().off();


or if you want all descendants:



$(#div1).find(*).off();

[#81342] Monday, December 17, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isham

Total Points: 69
Total Questions: 86
Total Answers: 86

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;