Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Lista</title>
- </head>
- <script>
- window.onload = () =>
- document
- .getElementsByTagName("form")[0]
- .addEventListener("submit", event => submitHandler(event));
- function submitHandler(event) {
- event.preventDefault();
- addBullet();
- document.getElementById("user-todo").value = "";
- }
- function clearList() {
- document.getElementById("items").innerHTML = "";
- }
- function addBullet() {
- let value = document.getElementById("user-todo").value;
- let bullet = document.createElement("li");
- bullet.appendChild(document.createTextNode(value));
- document.getElementById("items").appendChild(bullet);
- }
- </script>
- <body>
- <h1 id="title">Lista</h1>
- <form>
- <input type="text" id="user-todo" placeholder="Lista" required />
- </form>
- <h2 id="todo-header">Rzeczy:</h2>
- <ul id="items"></ul>
- <button id="clear" onclick="clearList()">Reset</button>
- <script></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement