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 trialMatthew Russo
3,871 PointsSet the text content of the a tag to be the value stored in the variable inputValue.
I'm having trouble with this challenge question. I've tried the querySelector(), getElementById(), and getElementsByTagName() methods on the a tag, but nothing worked. Any ideas what I might be doing wrong?
let inputValue = document.querySelector('input').value;
inputValue = document.querySelector('#link').textContent;
<!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>
2 Answers
Alexander Solberg
14,350 PointsRearrange your second line in app.js and see if you can figure it out :) you are very close!
Adam Beer
11,314 PointsUse let anchor variable on the new line and from the end delete .textContent. Now did you receive the value. On the new line use innerText. Hope this help!
Matthew Russo
3,871 PointsMatthew Russo
3,871 PointsThanks for the response. Nothing I've tried since yesterday has worked. Got another hint??
Alexander Solberg
14,350 PointsAlexander Solberg
14,350 PointsThing is that you're setting a new value for your variable, instead of using that variable to set the textContent of #link.
Try setting it up like this
document.querySelector('#link').textContent = inputValue;
This worked for me when I took the challenge :) hope it works for you too.
Matthew Russo
3,871 PointsMatthew Russo
3,871 PointsThat worked, thanks!