💾str.htmlToElement()
replit: toc
/**
* convert HTML into Element
*
* @example
*
* let div = `<div id="toc"></div>`.htmlToElement()
*
*/
String.prototype.htmlToElement = function () {
const template = document.createElement('template');
template.innerHTML = this.trim(); // remove text node of whitespace
return template.content.firstElementChild; // return Element (no Text nodes)
};
table of contents of a HTML page.
DOM ⟩ Element
SVGElement() - create/configure SVG element.
Last updated