2021-11-24 20:46:13 +05:30

26 lines
750 B
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>