Skip to content

Instantly share code, notes, and snippets.

@nestoralonso
Created September 28, 2020 16:35
Show Gist options
  • Save nestoralonso/ed46c4df83d82b22bc9584709493505c to your computer and use it in GitHub Desktop.
Save nestoralonso/ed46c4df83d82b22bc9584709493505c to your computer and use it in GitHub Desktop.
Creates a dom object node passing it the attributes
function createElem(name, attrs) {
const elem = document.createElement(name);
return Object.assign(elem, attrs);
}
// Example usage
const newDiv = createElem('div', { className: 'lol', style: 'width: 100px'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment