Mutation Observer for creating new elements
I am trying to make a function go off when a particular div is created. In the simplest of terms, I have something like this: <a href="" id="foo">Click me!</a> <script> $("#foo").live("click",function(e) { e.preventDefault(); $(this).append($("<div />").html("new div").attr("id","bar")); }); </script> Before, I had mutation events listen for the creation of div#bar - something like this: $("#bar").live("DOMNodeInserted", function(event) { console.log("a new div has been appended to the page"); }); Is there an equivalent using Mutation Observers? I tried attrchange.js featured on Can you have a