Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Making Changes to the DOM Styling Elements

The button to hide and show text works properly, however, the button does not transition back to "Hide list" and ...

remains on "Show list" TIA!

const toggleList = document.getElementById('toggleList'); const listDiv = document.querySelector('.list'); const input = document.querySelector('input'); const p = document.querySelector('p.description'); const button = document.querySelector('button');

toggleList.addEventListener('click', () => { if (listDiv.style.display == 'none') { toggleList.textConent = 'Hide list'; listDiv.style.display = 'block'; } else { toggleList.textContent = 'Show list'; listDiv.style.display = 'none'; } });

button.addEventListener('click', () => { p.innerHTML = input.value + ':';

1 Answer

Steven Parker
Steven Parker
229,921 Points

It's a little spelling error. The line that should change it to "hide" is setting the "textConent" property (with 3 "t"s) instead of "textContent" (4 "t"s).