Skip to content

Commit 5bc8165

Browse files
committed
New exercises
1 parent af7dd24 commit 5bc8165

File tree

19 files changed

+1076
-233
lines changed

19 files changed

+1076
-233
lines changed

.DS_Store

12 KB
Binary file not shown.

ShoppingList/app.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
let btn = document.querySelector("#button");
3+
4+
5+
btn.addEventListener('click', function () {
6+
addItem();
7+
});
8+
9+
function addItem() {
10+
let li = document.createElement('li');
11+
let inputValue = document.querySelector('#input').value;
12+
let elementText = document.createTextNode(inputValue);
13+
li.appendChild(elementText);
14+
if (inputValue === '') {
15+
alert('write something!!!');
16+
} else {
17+
document.querySelector("#ulList").appendChild(li);
18+
}
19+
document.querySelector('#input').value = "";
20+
// var span = document.createElement("SPAN");
21+
// var txt = document.createTextNode("x");
22+
// span.className = "close";
23+
// span.appendChild(txt);
24+
// li.appendChild(span);
25+
li.innerHTML += "<button onclick='deleteItem(this);'>Delete</button>";
26+
}
27+
function deleteItem(currentElement){
28+
currentElement.parentNode.parentNode.removeChild(currentElement.parentNode);
29+
}
30+
// let closeBtn = document.querySelector(".close");
31+
32+
33+
// closeBtn.addEventListener('click', function () {
34+
// removeItem();
35+
// });
36+
// function removeItem(){
37+
38+
// };
39+
40+
// for (i = 0; i < close.length; i++) {
41+
// close[i].onclick = function () {
42+
// var div = this.parentElement;
43+
// div.style.display = "none";
44+
// }
45+
// }

ShoppingList/index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<link rel="stylesheet" href="style.css">
8+
9+
<title>Shopping List</title>
10+
</head>
11+
<body>
12+
<form action="">
13+
<label for="">Enter a new Item </label>
14+
<input type="text" id="input" placeholder="Add Items...">
15+
<button type="button" id="button">Add Item</button>
16+
</form>
17+
<ul id="ulList">
18+
<li>asd</li>
19+
20+
</ul>
21+
<script src="app.js" defer></script>
22+
</body>
23+
</html>

ShoppingList/style.css

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
body{
2+
text-align: center;
3+
margin-top: 200px;
4+
}
5+
6+
/* Style the close button */
7+
.close {
8+
9+
padding: 12px 16px 12px 16px;
10+
}
11+
12+
.close:hover {
13+
background-color: #f44336;
14+
color: white;
15+
}

0 commit comments

Comments
 (0)