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

What am I doing wrong?

I have tried every way I can think of to solve this and treehouse is still saying it's wrong. What can I do?

app.js
let inputValue = document.getElementsByTagName('a').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>

6 Answers

Hi ! They ask for the value of the text input, not the link, you can then retrieve it thanks to its id :

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

Thank you!

Wait that didn't work

That's weird, it worked for me :/ Are you sure you copied without changing anything ?

Neil McPartlin
Neil McPartlin
14,662 Points

Hi Jackson. I can confirm that Johan has given you the correct answer for Challenge 1, I have copy/pasted as he suggested and it has worked for me.

So with Challenge 2, you should leave the answer to Challenge 1 in place and untouched, and one solution involves adding 2 more lines of code. I will just start them here...

let inputValue = document.getElementById('linkName').value; // leave untouched
let a = // follows a similar pattern to the line above, you must examine the html to find the id.
a.textContent = // what you defined in Challenge 1.

Okay thank you. Tree house is a little picky

It still won't work

Neil McPartlin
Neil McPartlin
14,662 Points

Please share with us your full answer to Challenge 2 which includes the answer to Challenge 1 as its line 1.