Skip to content

Instantly share code, notes, and snippets.

@the-architect
Created April 12, 2017 20:16
Show Gist options
  • Save the-architect/a86731021a4cfe491dbbb506fad51d44 to your computer and use it in GitHub Desktop.
Save the-architect/a86731021a4cfe491dbbb506fad51d44 to your computer and use it in GitHub Desktop.
ES6 Utility Class: Create a new element and attach it to another one
export const Utility = {
createElement: function(tagName = 'DIV', className, appendTo) {
let element = document.createElement(tagName);
element.className = className;
if(typeof appendTo !== 'undefined'){
appendTo.appendChild(element);
}
return element;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment