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 trialPaul Walker
28,904 PointsStore the value of the text input element in the variable inputValue.
Store the value of the text input element in the variable inputValue.
let inputValue = document.getElementById('linkName');
myButton.addEventListener('click', () => ({
= 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>
<button id="myButton">Input text</button>
</div>
<script src="app.js"></script>
</body>
</html>
6 Answers
Steven Parker
231,271 PointsYour top line is close.
You have selected the element using the id, now you just need to append ".value
" to it to get the value of that element.
But what is all that stuff below the top line? It doesn't seem related to the challenge at all, and it's not even complete code. You'll also need to remove that to pass the challenge.
Bhaskar Das
1,487 Pointslet inputValue = document.querySelector ('#linkName'); inputValue = inputValue.value;
Paul Walker
28,904 PointsGot it! Thanks Steven.
Shelley Brown
7,613 PointsNone of these solutions are working.
Steven Parker
231,271 PointsThe example shown above is not a correct solution, but some hints were given to help the poster fix it.
Unless you made the same exact errors, the hints might not be useful for you. You might do better to start a fresh question and show your own code in it.
Paul Walker
28,904 PointsThanks, Steven, I have already solved this problem. Thank you for your response.
Steven Parker
231,271 PointsThat comment was for Shelly, but good to see you're still around after all this time!
You can mark the question solved by choosing a "best answer". Happy coding!
Shelley Brown
7,613 PointsThanks Steven, I figured it out.