lomse
lomse

Reputation: 4165

Check if Div's content has been updated

I'm trying to check if a div's content is updated.

$(document).ready(function(){
   $('#main').bind('DOMNodeInserted', function() {
       alert("Div's content has been updated"); //Should display only once regarless the number of modified elements
   });
});

This code will alert Div's content has been updated the number of time the divs inside #main have been update

I would like it to alert only once, just to tell that, all the elements have been successfully updated. Any way to do this please? Thanks

Upvotes: 0

Views: 330

Answers (1)

Zach Saucier
Zach Saucier

Reputation: 25954

Use jQuery's .one

document).ready(function(){
  $('#main').one('DOMNodeInserted', function() {
    alert("Div's content has been updated"); //Should display only once regarless the number of modified elements
  });
});

Here's a demo

Upvotes: 4

Related Questions