Created
January 15, 2026 02:27
-
-
Save cybardev/4c9ca24003e1965566121b56510dbe82 to your computer and use it in GitHub Desktop.
VanillaJS TODO List Example
This file contains hidden or 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
| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>VanillaJS TODO List Example</title> | |
| <style> | |
| body { | |
| font-family: sans-serif; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <main> | |
| <section id="add-item"> | |
| <label for="name">Item Name: </label> | |
| <input type="text" name="name" id="name" required /> | |
| <input type="button" value="Add Item" onclick="addItem()" /> | |
| </section> | |
| <section id="todos"> | |
| <ul id="todo-list"></ul> | |
| </section> | |
| </main> | |
| <script src="script.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or 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
| const $ = (e) => document.querySelector(e); | |
| function todoItem(it) { | |
| return `<li><input type="checkbox" name="${it.toLowerCase()}"><label for="${it.toLowerCase()}">${it}</label></li>`; | |
| } | |
| function addItem() { | |
| document; | |
| $("#todo-list").insertAdjacentHTML("beforeend", todoItem($("#name").value)); | |
| $("#name").value = ""; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment