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 Making Changes to the DOM Modifying Elements

JS, Get and Set, Challenge Task 1 of 2. Wrong Answer, Not Sure Why

SOURCE: https://teamtreehouse.com/library/javascript-and-the-dom-3/making-changes-to-the-dom/modifying-elements

Challenge Task 1 of 2

"Select the <input> element and assign its value to the variable inputValue."

I put the following and it was apparently wrong::

const inputValue = document.querySelector('input');

I'm not sure why it's wrong, as it was the same code for the lesson on changing element attributes, where Guil Hernandez typed the following:

const myInput = document.querySelector('input');

Thanks, Graham Wadden.

const inputValue = document.querySelector('input');
<!DOCTYPE html>
      <title>DOM Manipulation</title>
    <link rel="stylesheet" href="style.css" />
      <div id="content">
        <label for="linkText">Link Text:</label>
        <input type="text" id="linkText" value="sample text">
        <p class="info"></p>
    <script src="app.js"></script>

2 Answers

Hi Buddy,

I'm also on the same module! Nice to see someone learning together.

so the task requires us to target the value for input. so you are missing .value at the back.

const inputValue = document.querySelector('input').value;

Hey Yang Sheng Toh!

Brilliant! ... I guess that's technically the second time you've passed this part of the challenge, once on your system, and now on mine :D ... So, on behalf of Treehouse "Well Done! You're doing great!"

Thanks for your help, I've looked back at the file I created from Guil Hernandez's tutorials and I now see what I was missing was buried in the "btnUpdate.addEventListener()" function: "headline.textContent = input.value". I was referring to that file when answering the question in the task, but it was as good as hidden in plain sight amongst all the code.

Cheers buddy!