Created
July 29, 2024 14:49
-
-
Save hctilg/549095625fcc5cfa2c0ab806621ca54e to your computer and use it in GitHub Desktop.
create Element From HTML using JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {String} HTML representing any number of sibling elements | |
* @return {NodeList} | |
*/ | |
const createElementFromHTML = (htmlString = '') => { | |
var template = document.createElement('template'); | |
template.innerHTML = htmlString; | |
return template.content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment