How, in JavaScript, can I search for a child element from this code?
(Sorry, I'm not an expert with naming things or making my code look "neat and organized.")
var thisWin = document.querySelector("#tempWindow").cloneNode(true);
bodyOrDocument = (document.documentElement || document.body)
bodyOrDocument.appendChild(thisWin)
I am cloning an element, and the clone has no classes or IDs, so I tried this:
windowId = random(0, 10000000).toString();
thisWin.setAttribute("id", windowId)
thisWiniFrame = document.querySelector("#" + windowId + " iframe");
But I get this error in the console:
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '#8722143 iframe' is not a valid selector.
I know the tag names are not reliable, but it's only for testing purposes anyways, so it's not really that important to me.
Anyways, does anybody know why is this error showing up? I have been stuck on this for a while.