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.
<div class='parent'>
<div>1</div>
<div>2</div>
</div>
<button id="add">Add to Div</button>
$(".parent").bind("DOMSubtreeModified", function() {
alert("div added");
});
$("#add").click(function() {
$(".parent").append("<div>3</div>");
});
try this:
$('.parent').on("DOMNodeInserted", function(){
//your code
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.