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

Set the text content of the a tag to be the value stored in the variable inputValue.

Set the text content of the a tag to be the value stored in the variable inputValue.

app.js
let inputValue =linkName.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>
        </div>
        <script src="app.js"></script>
    </body>
</html>

2 Answers

Adam Beer
Adam Beer
11,313 Points

Check the index.html file. The text field has an identifier. Use document.getElementById ('linkName').value;.

Steven Parker
Steven Parker
216,120 Points

While some browsers automatically create variables with the names of element id's (and the challenge lets you get away with it also), this should not be counted on. You should use one of the selection functions instead.

And task 2 is essentially the opposite of task 1, you'll swap the sides of the assignment, use a different selector, and access a different property.