Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM Making Changes to the DOM Set Inline Styles with the style Property

Joshua Munoz
Joshua Munoz
Courses Plus Student 7,072 Points

Issue: Set Inline Styles with the style Property (JavaScript and the DOM)

I'm running in to an issue btnToggle element in this lesson, i've been following the video step by step and have checked over my code multiple times and i can't seem to find the issue that is preventing me from hiding the list, here's the JavaScript and HTML i'm working with

const btnUpdate = document.querySelector('.btn-main');
const btnToggle = document.querySelector('btn-toggle');

btnUpdate.addEventListener('click', () => {
  const headline = document.getElementById('headline');
  const input = document.querySelector('.input-main');

  headline.className = 'grow';
  headline.textContent = input.value;
  input.value = '';

btnToggle.addEventListener('click', () => {
 const listContainer =  document.querySelector('.list-container');
  listContainer.style.display = 'none';

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript and the DOM</title>
    <link href="css/style.css" rel="stylesheet">
    <div class="wrapper">
        <h1 id="headline">My Day</h1>
        <div class="group">
          <label for="main">What's your task?</label>
          <input type="text" id="main" class="input-main">
          <button class="btn-main">Update Heading</button>

      <button class="btn-toggle">Hide List</button>

      <div class="list-container">
        <ul aria-live="polite">
          <li>Make coffee</li>
          <li class='highlight'>Practice JavaScript</li>
          <li>Walk the cat</li>
          <li>Watch a Treehouse video</li>
          <li class='highlight'>Go swimming</li>
          <li class='highlight'>Play my guitar</li>
        <button class="btn-remove">Remove Last Task</button>

    <script src="app.js"></script>

1 Answer

Steven Parker
Steven Parker
216,812 Points

The code attempts to use the selector "btn-toggle" to find the button, but a class selector must be preceded by a period (".btn-toggle").

Joshua Munoz
Joshua Munoz
Courses Plus Student 7,072 Points

Thank you so much! I figured it was something simple. I was probably just looking at my screen to long that day. 😂