-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoDo.js
More file actions
28 lines (22 loc) · 893 Bytes
/
toDo.js
File metadata and controls
28 lines (22 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const input = document.getElementById("toDo_add");
input.addEventListener('keypress', (e) => {
if (e.key == "Enter" && input.value != "") {
let item = `<div>
<input type="checkbox" onchange='handleChange(this)'>
<span>${input.value}</span>
<button id="toDo-removeItem" onClick="this.parentElement.remove()" style="float: right; font-size: 10px">REMOVE</button
</div>
`
document.getElementById("toDo-items").innerHTML += item;
input.value = ""
}
})
function handleChange(checkbox) {
if(checkbox.checked == true){
checkbox.parentElement.style.opacity = "0.5"
checkbox.parentElement.style.textDecoration = "line-through"
}else{
checkbox.parentElement.style.opacity = "1"
checkbox.parentElement.style.textDecoration = "none"
}
}