Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
./script.js
./style.css
29 changes: 17 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<!DOCTYPE html>
<html>

<head>
<title>Todo List</title>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Todo List</title>
<link rel="stylesheet" type="text/css" href="style2.css">
</head>

<body>
<div class="container">
<h1>Todo List</h1>
<form id="todoForm">
<input type="text" id="todoInput" placeholder="Enter a task">
<button type="submit">Add</button>
</form>
<ul id="todoList"></ul>
</div>
<div class="container">
<h1>Todo List</h1>
<form id="todoForm">
<input type="text" id="todoInput" placeholder="Enter a task">
<span onclick="additem()" id="submit" class="add">Add</span>
</form>
<ul id="todoList">

<script src="script.js"></script>
</ul>
</div>

<script src="script.js"></script>
</body>
</html>

</html>
22 changes: 22 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const input = document.getElementById("todoInput");
const list = document.getElementById("todoList");

// add new task
function additem() {
if (input.value == "") {
alert("please add your tasks")
} else {
let li = document.createElement("li");
li.innerHTML = input.value;
list.appendChild(li);

}
input.value = "";
}

// check the complete task
list.addEventListener('click', function(ev) {
if (ev.target.tagName === 'LI') {
ev.target.classList.toggle('checked');
}
}, false);
53 changes: 53 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
display: flex;
justify-content: center;
align-items: center;
min-height: 50vh;
background-color: lightgrey;
color: black;
}

ul li {
font-size: 30px;
font-weight: 20px;
list-style: none;
top: 10px;
padding: 12px 12px;
right: -25px;
user-select: none;
cursor: pointer;
position: relative;
}

ul li::before {
content: '';
position: absolute;
height: 30px;
width: 30px;
left: -20px;
background-image: url(unchecked.png);
background-size: cover;
background-position: center;
border-radius: 50%;
}

ul li.checked {
text-decoration: line-through;
}

ul li.checked {
content: '';
position: absolute;
height: 18px;
width: 18px;
left: -20px;
background-image: url(check.png);
background-position: center;
background-size: cover;
}