Javascript examples for DOM:Event
Handle DOM element inserted event with DOMNodeInserted
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w . ja v a 2 s . c om var container = document.getElementById('container'); container.addEventListener('DOMNodeInserted', function () { console.log('A node was inserted into #container'); }); var div = document.createElement('div'); div.innerHTML = 'I\'m a div!'; container.appendChild(div); } </script> </head> <body> <div id="container"></div> </body> </html>