Skip to content

Commit 517690f

Browse files
authored
Add files via upload
1 parent 21890c5 commit 517690f

3 files changed

Lines changed: 87 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>Add List Items Dynamicaly</title>
7+
<link rel="stylesheet" href="style.css">
8+
</head>
9+
<body>
10+
<div class="container">
11+
<h1>Add List Items Dynamicaly</h1>
12+
<div class="input-section">
13+
<input type="text" id="inputText" placeholder="Enter your text...">
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const input = document.getElementById("inputText");
2+
const button = document.getElementById("click");
3+
const list = document.getElementById("taskList");
4+
5+
button.addEventListener("click", () => {
6+
const userInput = input.value.trim(); // input = takes value, trim = ignores extra spaces
7+
8+
if (userInput !== "") {
9+
const listItem = document.createElement("li");
10+
listItem.textContent = userInput;
11+
12+
list.appendChild(listItem);
13+
14+
// clear input
15+
input.value = "";
16+
}
17+
else {
18+
aleret ("Enter some text!")
19+
}
20+
});
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
body {
2+
text-align: center;
3+
padding: 100px;
4+
background-color: blueviolet;
5+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
6+
}
7+
8+
.container {
9+
background-color: white;
10+
padding: 20px;
11+
width: 30%;
12+
margin: auto;
13+
border: none;
14+
border-radius: 50px;
15+
}
16+
17+
input {
18+
width: 60%;
19+
padding: 10px;
20+
border: 3px solid grey;
21+
border-radius: 15px;
22+
}
23+
24+
button {
25+
font-size: 15px;
26+
padding: 10px;
27+
border: 3px solid greenyellow;
28+
border-radius: 15px;
29+
background-color: greenyellow;
30+
font-weight: 600;
31+
cursor: pointer;
32+
}
33+
34+
li {
35+
list-style: none;
36+
background-color: #e3dede;
37+
padding: 6px 6px 6px 10px;
38+
margin-bottom: 10px;
39+
border-radius: 10px;
40+
text-align: start;
41+
width: 85%;
42+
}
43+
44+
li:hover {
45+
background-color: #bdbdbd;
46+
}

0 commit comments

Comments
 (0)