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 trialjdee
6,655 PointsWhy isn't this code accepted as an answer?
In a firefox browser console, this statement returns the entire <input> element needed; however, it is not accepted as the answer. Why?
var inputValue = document.querySelector('input[id=linkName]')
Michael Williams
Courses Plus Student 8,059 PointsYou're doing great, and I understand the logic, but Kevin is right. They want you to use the getEelementById
method, which will get you halfway there. Then, you still need to set the value of the inputValue
variable equal to the value in the html element.
HINT: You'll need to write another line of code to get there. If you're still stuck, rewatch this video, and it will help you out. I know I'm not giving you the right answer right out of the gate, but you'll learn the concepts better this way.
jdee
6,655 PointsThanks to both of you.
1 Answer
Steven Parker
231,248 PointsAs Michael pointed out, you just need to access the value instead of the element itself.
But while your selector works as-is, it doesn't need to be so verbose. Since all ID's are unique, you can select an element using only it's ID. So instead of 'input[id=linkName]'
, you could simply use '#linkName'
.
Kevin Gates
15,053 PointsKevin Gates
15,053 PointsWithout knowing the question and the fuller context, it's likely because they are looking for you to use the method they just taught you, versus the method you used above.
Additionally, without seeing if you set the "linkName" correctly, it's hard to tell.