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) Getting a Handle on the DOM Practice Selecting Elements

Jaime Castillo
Jaime Castillo
5,800 Points

JS and Dom

let footerImages = document.querySelectorAll('footer a'); //why doesn't it work? How does nodes work?

js/app.js
let navigationLinks; navigationLinks = document.querySelectorAll('nav a');
let galleryLinks = document.querySelectorAll('section a');
let footerImages = document.querySelectorAll('footer a');
index.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Nick Pettit | Designer</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body>
    <header>
      <a href="index.html" id="logo">
        <h1>Nick Pettit</h1>
        <h2>Designer</h2>
      </a>
      <nav>
        <ul>
          <li><a href="index.html" class="selected">Portfolio</a></li>
          <li><a href="about.html">About</a></li>
          <li><a href="contact.html">Contact</a></li>
        </ul>
      </nav>
    </header>
    <div id="wrapper">
      <section>
        <ul id="gallery">
        </ul>
      </section>
      <footer>
        <a href="http://twitter.com/nickrp"><img src="img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a>
        <a href="http://facebook.com/nickpettit"><img src="img/facebook-wrap.png" alt="Facebook Logo" class="social-icon"></a>
        <p>&copy; 2016 Nick Pettit.</p>
      </footer>
    </div>
  <script src="js/app.js"></script>
  </body>
</html>

1 Answer

Steven Parker
Steven Parker
231,269 Points

The instructions say to "select all images in the footer element", but the code shown here is selecting all links in the footer (instead of images).

Also, while the code for task 2 happened to select the correct set of elements, it wasn't coded according to the instructions. The task 2 instructions said, "select all links in the unordered list with the id of gallery"* so it would have been more accurate to use the selector "#gallery a".

And it looks like some lines have been removed from index.html. For this challenge, that file should remain as-is.