Create shoppingList
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head> <title>Complete JavaScript Course</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<input type="text" id="addItem">
|
||||||
|
<input type="button" id="addNew" value="Add to List">
|
||||||
|
</div>
|
||||||
|
<h1>Shopping List</h1>
|
||||||
|
<ol id="sList"> </ol>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const myItem = document.querySelector('#addItem');
|
||||||
|
const btn = document.querySelector('#addNew');
|
||||||
|
const myList = document.querySelector('#sList');
|
||||||
|
btn.addEventListener('click', (e) => {
|
||||||
|
let val = myItem.value;
|
||||||
|
const li = document.createElement('li');
|
||||||
|
li.textContent = val;
|
||||||
|
myList.append(li);
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user