Skip to content

Instantly share code, notes, and snippets.

@hkfoster
Last active August 29, 2015 14:02
Show Gist options
  • Save hkfoster/3245eddd3f4867a5ba6e to your computer and use it in GitHub Desktop.
Save hkfoster/3245eddd3f4867a5ba6e to your computer and use it in GitHub Desktop.
Native JS Node Maker Function
/**
* Node Maker Function
* @author Kyle Foster
*/
var makeNode = function( parent, content ) {
var node = document.createElement( parent );
if ( content ) node.innerHTML = content;
return node;
};
// Create node w/ content
var text = makeNode( 'tr', '<td>Simple text</td>' );
// Append to body
document.body.appendChild( text );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment