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

Jase Hackman
Jase Hackman
4,320 Points

I'm struggling to resolve this challenge.

I've rewritten my code a few different ways but I cannot seem to find the correct answer.

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

Hello Jase,

For task-1, your line-1 is okay.

let inputValue = document.getElementById('linkName').value;

However for task-2, you'll first need to select the a element and then set it's textContent property to inputValue.

This can be achieved by:

let link = document.getElementById('link');
link.textContent = inputValue;

or:

document.getElementById('link').textContent = inputValue;
Dustin Sigurdson
Dustin Sigurdson
7,668 Points

Hi Jase,

I'm still new so forgive my explanation.

Your first link of code looks good to me.

let inputValue = document.getElementById('linkName').value;

Your second line of code seems off to me.

It looks like you have tried to reset the inputValue variables text content and value.

The instructions are to change the text content of the "a" tag (with the ID of 'link') to the value of the inputbox content.

I hope this helps!