-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day3.js
40 lines (36 loc) · 1.48 KB
/
Day3.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
var text_input=document.getElementById("text");
document.querySelector("#submit").addEventListener("click",printList);
function printList(){
if(text_input.value!=""){
var list_value=text_input.value; //list value
var list_item=document.createElement("p"); //Creating a p element
var list_check_btn=document.createElement("i"); //Creating check button
var list_delete_btn=document.createElement("i"); //Creating delete button
document.querySelector("div").appendChild(list_item); //put p inside div element
list_item.textContent=list_value;//change the content of p element
list_item.appendChild(list_check_btn);
var span_space=document.createElement("span");
span_space.textContent=" ";
list_item.appendChild(span_space);
list_item.appendChild(list_delete_btn);
list_check_btn.classList.add("fa-check");
list_check_btn.classList.add("fas");
list_check_btn.classList.add("fa-xs");
list_check_btn.classList.add("icon2");
list_delete_btn.classList.add("fa-trash-alt");
list_delete_btn.classList.add("far");
list_delete_btn.classList.add("fa-xs");
list_delete_btn.classList.add("icon1");
list_item.classList.add("text_items");
text_input.value=""; //Just Clearing the input field
//deleting and checking
list_delete_btn.addEventListener("click",deleteTask);
list_check_btn.addEventListener("click",checkTask);
function deleteTask(x){
x.target.parentElement.remove();
}
function checkTask(x){
x.target.parentElement.classList.toggle("linedraw");
}
}
}