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 trialNour El-din El-helw
8,241 PointsWhat am I doing wrong?
There is probably something wrong but I can't find it, so can someone please help?
This is the task : Set the text content of the a tag to be the value stored in the variable inputValue.
let inputValue = document.querySelector('a').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
Adam Beer
11,314 PointsSelect the id with getElementById() . After the getElementById() use .value and store the input value inside the inputValue variable. Hope this help.
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsHey Nour El-din El-helw , they are saying to set the textContent of the anchor
element to the value of input
element which gets stored in inputValue variable..
What you are doing is - getting the textContent of anchor
element.
The code will be -
let inputValue = document.querySelector('#linkName').value; // get the value of *input* element
document.querySelector('a').textContent = inputValue ; // set the *textContent* of *a* to inputValue
Hope it helps :)
Nour El-din El-helw
8,241 PointsYeah, thanks man this really helped.
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsYou are most welcome :)
Nour El-din El-helw
8,241 PointsNour El-din El-helw
8,241 PointsYou probably said the right answer, same as Aakash Srivastav but I didn't get it really well because I needed some details.
Adam Beer
11,314 PointsAdam Beer
11,314 PointsI'm sorry. We don't write the ready code, so you can't learn. We are givin guidelines. Next time I try to pay more attention for the example. Happy coding!
Nour El-din El-helw
8,241 PointsNour El-din El-helw
8,241 PointsBro..It's not your problem. It's mine I usually don't get stuff except with an example or so.