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 trialRyan Schmelter
9,710 PointsCan anyone please post their solution to this. I'm really stuck with what's being asked here.
Any help would be appreciated.
let inputValue = document.getElementById('linkName');
inputValue = inputValue.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>
3 Answers
Ryan S
27,276 PointsHey Ryan,
Nice work, your logic is exactly correct. But you are missing one little detail: your variable "a
" needs to be declared first using let
. Fix that and it will pass.
Ryan S
27,276 PointsHi Ryan,
Yeah the wording on Task 2 is a little confusing. I'll try and lay it out for you so you can have another go at it.
- Select the <a> tag (hint: you can use the "
.getElementById()
" method again and store it in a variable.) - Access the text content of the selected <a> tag by using the "
.textContent
" attribute. - Update the "
.textContent
" attribute of the <a> tag such that it is equal to the "inputValue" from Task 1.
See if this helps you solve it. #2 and #3 can be done in one line. If you still need some help just let me know.
Ryan Schmelter
9,710 PointsHey Ryan,
Thanks for your response. This was my thinking here, but I'm obviously still doing something wrong. Here's my code. Any help would be greatly appreciated.
let inputValue = document.querySelector('#linkName'); inputValue = inputValue.value; a = document.querySelector('#link'); a.textContent = inputValue;
Ryan Schmelter
9,710 PointsSo much grief for such a stupid mistake. Thanks - I really appreciate it.
Ryan S
27,276 PointsNo problem. Things like that are easy to miss when your mind is focused on figuring out the logic. Plus the challenge errors are sometimes a little short on information.