Skip to content

Instantly share code, notes, and snippets.

@hunsly
Created July 21, 2022 17:57
Show Gist options
  • Save hunsly/e8a628286bf4da278cf4fa592b415211 to your computer and use it in GitHub Desktop.
Save hunsly/e8a628286bf4da278cf4fa592b415211 to your computer and use it in GitHub Desktop.
/**
Example:
getHTMLSubElements(HTML, '.cssSelector');
getHTMLSubElements(HTML, '#idSelector');
getHTMLSubElements(HTML, 'SubTagName .cssSelector');
*/
function getHTMLSubElements(HTML, sel) {
let root = document.createElement("DIV");
root.innerHTML = HTML;
return root.querySelector(sel);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment