Created
April 7, 2022 12:49
-
-
Save LouisHrg/5d005a1e836dc503f7888cf22f8a94ea to your computer and use it in GitHub Desktop.
CreateElement
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
const createElement = (type, config, parent = null) => { | |
const element = document.createElement(type); | |
if(config && config.text) { | |
element.innerHTML = config.text; | |
} | |
if(!parent) { | |
root.appendChild(element); | |
} else { | |
parent.appendChild(element) | |
} | |
return element; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment