Bummer! You have been redirected as the page you requested could not be found.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Interacting with the DOM!
You have completed Interacting with the DOM!
We can use properties to select elements based on their relationships with other elements. Here we'll select all the children of an element with the children property.
Code Snippet
btnCreate.addEventListener('click', () => {
let ul = document.getElementsByTagName('ul')[0];
const input = document.querySelector('.input-main');
let li = document.createElement('li');
li.textContent = input.value;
ul.appendChild(li);
input.value = '';
});
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up