Create new list item and add to DOM
Extend the JavaScript code below to interact with the displayed HTML elements.
Enter a new todo in the input field. Once you click the button, the new todo item should appear at the bottom of the list.
Confirm your code by creating a new todo!
Enter a new todo in the input field. Once you click the button, the new todo item should appear at the bottom of the list.
Confirm your code by creating a new todo!
- Read a book
- Lunch with Caro
- Feed the dog
View
<input type="text" id="input" placeholder="To do..."/>
<button type="button" id="button">Add</button>
<ul id="list">
<li>Read a book</li><li>Lunch with Caro</li><li>Feed the dog</li>
</ul>
HTML
const button = document.getElementById('button');
button.addEventListener('click' , () => {
// type in your code here
});
Javascript