javascript - Get elements that have not been added to the DOM -


if create new html element using document.createelement, not add dom, there way find it? method of document, seems logical might become property of document.

example:

(function(){     document.createelement("a"); })();  console.log(document.getelementsbytagname("a").length); // -> 0 

i understand why above example doesn't work. there alternative?

you're creating elements, without insterting them in dom.

you need store them if want know how many are.

var myelements = []: var elem = document.createelement("a"); myelements.push(elem); myelements.length; // use length needs 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -