This file contains 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
// 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(e.target.value)); | |
// Create a text node | |
const domText = document.createTextNode(""); | |
// Set text node content | |
domText["nodeValue"] = "Foo"; | |
// Append an element | |
domRoot.appendChild(domInput); | |
// Append a text node (same as previous) | |
domRoot.appendChild(domText); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment