Konstantin Mokhov Konstantin Mokhov - 2 months ago 6
jQuery Question

event, when div is changed

I have some DOM elements, like this

<div class='parent'>
<div>1</div>
<div>2</div>
</div>


How I can track event, when 'parent' div has changed? As example I'm add
<div>3</div>
programmatically, with
append()
, or i'm drag div3 to 'parent' div.

Answer

try this:

$('.parent').on("DOMNodeInserted", function(){
  //your code
});