Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
48
rated 0 times [  49] [ 1]  / answers: 1 / hits: 78227  / 11 Years ago, fri, november 22, 2013, 12:00:00

Say I had a div#parent and I append and remove elements to it using jquery. How would I be able to detect when such an event happens on the div#parent element?


More From » jquery

 Answers
54

Use Mutation Observers as suggested by @Qantas in his answer






Following methods are deprecated



You can use DOMNodeInserted and DOMNodeRemoved



$(#parent).on('DOMNodeInserted', function(e) {
console.log(e.target, ' was inserted');
});

$(#parent).on('DOMNodeRemoved', function(e) {
console.log(e.target, ' was removed');
});


MDN Docs


[#74110] Thursday, November 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eddiejoshb

Total Points: 659
Total Questions: 105
Total Answers: 100

Location: Singapore
Member since Sat, Jul 25, 2020
4 Years ago
;