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 trial

JavaScript JavaScript and the DOM (Retiring) Making Changes to the DOM Modifying Elements

Paul Walker
Paul Walker
28,904 Points

Store the value of the text input element in the variable inputValue.

Store the value of the text input element in the variable inputValue.

app.js
let inputValue = document.getElementById('linkName');


myButton.addEventListener('click', () => ({
    = inputValue.value;
});
index.html
<!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
Steven Parker
231,269 Points

Your 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.

let inputValue = document.querySelector ('#linkName'); inputValue = inputValue.value;

Paul Walker
Paul Walker
28,904 Points

Got it! Thanks Steven.

None of these solutions are working.

Steven Parker
Steven Parker
231,269 Points

The 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
Paul Walker
28,904 Points

Thanks, Steven, I have already solved this problem. Thank you for your response.

Steven Parker
Steven Parker
231,269 Points

That 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!

Thanks Steven, I figured it out.