Skip to content

Commit 3cacbf2

Browse files
authored
Add files via upload
1 parent 517690f commit 3cacbf2

3 files changed

Lines changed: 108 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Delete List Items Dynamically</title>
7+
<link rel="stylesheet" href="style.css">
8+
</head>
9+
<body>
10+
<div class="container">
11+
<h1>Delete List Items Dynamically</h1>
12+
<div class="input-section">
13+
<input type="text" id="taskInput" placeholder="Enter your task...">
14+
<button id="click">Add Task</button>
15+
</div>
16+
<ul id="taskList"></ul>
17+
</div>
18+
19+
<script src="script.js"></script>
20+
</body>
21+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const input = document.getElementById("taskInput");
2+
const button = document.getElementById("click");
3+
const list = document.getElementById("taskList");
4+
5+
button.addEventListener("click", () => {
6+
const inputText = input.value.trim();
7+
8+
if (inputText === "") return;
9+
10+
// create list item
11+
const listItem = document.createElement("li");
12+
listItem.textContent = inputText;
13+
14+
// create delete button
15+
const delBtn = document.createElement("button");
16+
delBtn.textContent = "Delete";
17+
18+
delBtn.addEventListener("click", () => {
19+
listItem.remove();
20+
});
21+
22+
listItem.appendChild(delBtn);
23+
24+
list.appendChild(listItem);
25+
26+
input.value = "";
27+
})
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
body {
2+
padding: 100px;
3+
text-align: center;
4+
background: linear-gradient(to right, #2624ac, #64db46);
5+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
6+
}
7+
8+
.container {
9+
background-color: white;
10+
padding: 30px;
11+
width: 30%;
12+
margin: auto;
13+
border: none;
14+
border-radius: 50px;
15+
}
16+
17+
.input-section {
18+
display: flex;
19+
align-items: center;
20+
justify-content: center;
21+
gap: 10px;
22+
}
23+
24+
input {
25+
padding: 10px;
26+
font-size: 13px;
27+
border: 3px solid grey;
28+
border-radius: 10px;
29+
width: 60%;
30+
}
31+
32+
button {
33+
background-color: chartreuse;
34+
font-weight: 700;
35+
font-size: 15px;
36+
padding: 8px 20px;
37+
cursor: pointer;
38+
border: 3px solid chartreuse;
39+
border-radius: 10px;
40+
}
41+
42+
li {
43+
padding: 8px 12px;
44+
border: none;
45+
border-radius: 10px;
46+
background-color: burlywood;
47+
list-style: none;
48+
margin-bottom: 10px;
49+
width: 85%;
50+
text-align: left;
51+
display: flex;
52+
justify-content: space-between;
53+
align-items: center;
54+
}
55+
56+
li button {
57+
background-color: cornflowerblue;
58+
padding: 8px 10px;
59+
border: none;
60+
}

0 commit comments

Comments
 (0)