Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

olu adesina
23,007 Pointshow do i store the value of a tag
need help here
let inputValue =document.querySelector('#link').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

Steven Parker
221,070 PointsRight method, wrong tag.
You're getting the value the right way, but you're selecting the element with an ID of "link", which is the anchor (link) element. But the instructions asked you to select the text input element instead (which has an ID of "linkName").
olu adesina
23,007 Pointsolu adesina
23,007 Pointsi passed that task its asking me 'Set the text content of the a tag to be the value stored in the variable inputValue'
Steven Parker
221,070 PointsSteven Parker
221,070 PointsWell, you know how to select that element (it was the one you had selected by mistake last time). But instead of the value property, this time you want the textContent property. Other than that, it's just swapping the sides of the assignment.
olu adesina
23,007 Pointsolu adesina
23,007 Pointslet inputValue = document.querySelector('#link').textContent;
//still not getting it HELP PLEASE
Steven Parker
221,070 PointsSteven Parker
221,070 PointsRemember what I said about "swapping the sides of the assignment":
document.querySelector('#link').textContent = inputValue;
olu adesina
23,007 Pointsolu adesina
23,007 Pointsare we swapping the sides of the assignment because we are reassigning a new value to the variable? and if so would it work normally if u didn't swap
Steven Parker
221,070 PointsSteven Parker
221,070 PointsIn an assignment, the thing being assigned goes on the left side.
In task 1, you assigned the variable, so the variable name is on the left side of the equal sign.
But in task 2, you are using the value that you stored in the variable to assign the text content of the "a" element. So the variable name goes on the right side of the equal sign.