create a HTMLCollection

I think this is the proper way of creating HTMLCollection, which is handled by the browser. var docFragment = document.createDocumentFragment(); docFragment.appendChild(node1); docFragment.appendChild(node2); var myHTMLCollection = docFragment.children; Refs.: https://stackoverflow.com/a/35969890/10018427 https://developer.mozilla.org/en-US/docs/Web/API/NodeList https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection https://www.w3schools.com/js/js_htmldom_nodelist.asp

Mutation Observer for creating new elements

This is code that listens for mutations on the childlist of #foo and checks to see if a child with the id of bar is added. MutationObserver = window.MutationObserver || window.WebKitMutationObserver; $(“#foo”).live(“click”,function(e) { e.preventDefault(); $(this).append($(“<div />”).html(“new div”).attr(“id”,”bar”)); }); // define a new observer var obs = new MutationObserver(function(mutations, observer) { // look through all mutations … Read more