Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
220,378 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
220,378 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
220,378 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.