Skip to content
Snippets Groups Projects
Commit 709b84bb authored by Minhao Qiu's avatar Minhao Qiu
Browse files

add todo list

parent a75fa50d
Branches
No related tags found
No related merge requests found
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelector("#new-task").onsubmit = () => {
const li = document.createElement("li");
li.innerHTML = document.querySelector("#task").value;
// add new item to the task list
document.querySelector("#tasks").append(li);
// clear the input field
document.querySelector("#task").value = "";
// stop form from submitting
return false;
};
});
</script>
</head>
<body>
<h1>Tasks</h1>
<ul id="tasks">
</ul>
<form id="new-task">
<input id="task" autocomplete="off" autofocus placeholder="New Task" type="text">
<input type="submit">
</form>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment