Skip to content

Instantly share code, notes, and snippets.

Last active April 25, 2017 21:35
What would you like to do?
// Get an element by id
const domRoot = document.getElementById("root");
// Create a new element given a tag name
const domInput = document.createElement("input");
// Set properties
domInput["type"] = "text";
domInput["value"] = "Hi world";
domInput["className"] = "my-class";
// Listen to events
domInput.addEventListener("change", e => alert(;
// Create a text node
const domText = document.createTextNode("");
// Set text node content
domText["nodeValue"] = "Foo";
// Append an element
// Append a text node (same as previous)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment