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 trialGraham Wadden
5,089 PointsJS, Get and Set, Challenge Task 1 of 2. Wrong Answer, Not Sure Why
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>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<div id="content">
<label for="linkText">Link Text:</label>
<input type="text" id="linkText" value="sample text">
<p class="info"></p>
</div>
<script src="app.js"></script>
</body>
</html>
2 Answers
Yang Sheng Toh
Full Stack JavaScript Techdegree Student 9,364 PointsHi 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;
Graham Wadden
5,089 PointsHey 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!