-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (35 loc) · 1.14 KB
/
index.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
let textValue = document.querySelector("#insert");
let addbtn = document.querySelector("#add");
let list = document.querySelector(".list");
let month = [" Jan "," Feb "," Mar "," April "," May "," June "," July "," Aug "," Sept "," Oct "," Nov "," Dec "];
let date = new Date();
let fulldate = date.getDate() + month[date.getMonth()] + date.getFullYear();
document.querySelector(".date").innerHTML=fulldate;
textValue.addEventListener("keyup" , function(event){
if(event.keyCode===13){
var li = document.createElement("li");
var t = document.createTextNode(textValue.value);
li.appendChild(t);
document.querySelector("ul").appendChild(li);
textValue.value ="";
addbtn.click();
}
});
addbtn.addEventListener("click" , function(){
if(textValue.value=="")
{
textValue.value='';
}
else{
var li = document.createElement("li");
var t = document.createTextNode(textValue.value);
li.appendChild(t);
document.querySelector("ul").appendChild(li);
textValue.value ="";
}
});
list.addEventListener('click', function(ev) {
if (ev.target.tagName === 'LI') {
ev.target.classList.toggle('checked');
}
}, false);