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

I'm stuck on challenge Task 2 of 2..Help!

https://teamtreehouse.com/library/javascript-and-the-dom-2/making-changes-to-the-dom/modifying-elements

app.js
const input = document.querySelector('input');

let inputValue = input.value;
let tag = document.querySelector('a');
inputValue = tag.textContent;
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>

4 Answers

Jawann Carmona
Jawann Carmona
19,556 Points

Hey, the wording for this question might be confusing. It's asking for you to make the textContent of the tag equal the value of the inputValue variable.

So it should look like this:

const input = document.querySelector('input');

let inputValue = input.value;
let tag = document.querySelector('a');
tag.textContent = inputValue;

Before, you were actually changing the value of inputValue to be whatever the textContent of 'a' is.

Wow, that was an awesome breakdown, thanks man!

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

let link = document.querySelector('#link');

link.textContent = inputValue;

I found that this worked for me

Thanks a bunch!

Wow, that was an awesome breakdown, thanks man!

Thanks Mr Woods,

Your answer made it happen and told me clearly where and how i went wrong. I missed adding .value at the end of line.