I have the following code however it does not work:
let dummyDOM = document.createElement( 'html' );
dummyDOM.innerHTML = text;
const html = dummyDOM.getElementById("someID");
I receive: Uncaught (in promise) TypeError: dummyDOM.getElementById is not a function
I know how to get elements by class name but I have not seen a way to get elements by ID. Is this possible with htmlcollection?
Under usage notes from MDN:
That means a regular element doesn't have this method. However, regular elements still have a
querySelectormethod, that gets the first element found that matches a CSS selector.Or, if you are planning to add
dummyDOMto the page, you could just use the originalgetElementById:But what you really need is a proper Document, which you can do with
createDocument: