Skip to content

Instantly share code, notes, and snippets.

@Draketheb4dass
Created November 27, 2019 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Draketheb4dass/7ea65dad27f76f912d5c1c10618f1de2 to your computer and use it in GitHub Desktop.
Save Draketheb4dass/7ea65dad27f76f912d5c1c10618f1de2 to your computer and use it in GitHub Desktop.
Todo DOM manipulation
<!DOCTYPE html>
<html>
<body>
<ul id="myList"></ul>
<input id="myInput" />
<button onclick="addItem()">Add</button>
<script>
function addItem() {
var node = document.createElement("LI");
var inputValue = document.getElementById("myInput").value;
var textnode = document.createTextNode(inputValue);
node.appendChild(textnode);
document.getElementById("myList").appendChild(node);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment