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 trialJonathan Ambriz
Courses Plus Student 3,902 PointsThis question is really difficult for me to understand for some reason. Would love any explanation or hints.
Not sure how to use the id '#idName' and input.value in a querySelector statement together.
var inputValue = document.querySelector('#linkName value');
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<div id="content">
<label>Link Name:</label>
<input type="text" id="linkName">
<a id="link" href="https://teamtreehouse.com"></a>
</div>
<script src="app.js"></script>
</body>
</html>
1 Answer
Rabin Gharti Magar
Front End Web Development Techdegree Graduate 20,928 PointsHey Jonathan Ambriz,
You were very close on the first part of the challenge, you simply need to store a value
inside inputValue
variable and you can do this by using a value property
after selecting input element
with the id of linkName
. The value property
sets or returns the value of the value attribute of a text field.
Here's the final version:
var inputValue = document.querySelector('#linkName').value;
To understand how value property
works, check out this website: https://www.w3schools.com/JSREF/prop_attr_value.asp
Hope this helps!