-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
34 lines (33 loc) · 826 Bytes
/
script.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
var listcontainer=document.getElementById("task-container")
$("button").on("click",function(){
if($("#input-box").val()===''){
alert("write something")
}
else{
let li=$("<li>",{
html: $("#input-box").val()
})
$("#task-container").append(li);
let span = $("<span>",{
html: "\u00d7"
})
$("li").append(span)
}
$("#input-box").val('')
saveData() ;
});
$("ul").on("click","li", function(event){
$(this).toggleClass("done");
saveData() ;
})
$("ul").on("click","span", function(event){
$(this).closest("li").remove();
saveData() ;
})
function saveData() {
localStorage.setItem("data", listcontainer.innerHTML);
}
function showTask() {
listcontainer.innerHTML = localStorage.getItem("data");
}
showTask();