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

JavaScript and the DOM -> Challenge Task 2 of 2

Task 1 was to get the value of the input element and assign it to the variable inputValue. I was able to do this.

For Task 2, I need to get a handle to the link, a, and set its text equal to inputValue, from Task 1. I've been trying various ideas, but I continue to receive the "Bummer".

app.js
let inputValue = document.getElementById('linkName').value;
document.getElementById('link').text = inputValue;
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

Steven Parker
Steven Parker
231,269 Points

You are really close! The instructions say, "Set the text content of the a tag ...", but the name of the property they are referring to is not "text" but "textContent".

In actual practice, "text" is a synonym for "textContent" on an anchor element, but the challenge is apparently requiring the use of the property common to all Node objects.

Aha! Eureka! Voila! Thank you!