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

Katie Jordan
Katie Jordan
7,842 Points

Why Wont This Work...?

let linkName = document.getElementById('linkName').value() linkName.textConent('a')

This is my attempt at the answer but its not working... can someone point me in the right direction please?

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

1 Answer

Brian Jensen
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Brian Jensen
Treehouse Staff

You have to reassign the output of "a" back into the linkName variable.

This is how I solved it:

let linkName = document.querySelector('input').value;
document.getElementById('link').textContent = linkName;

Hey Brian, I've been grinding my teeth thinking about learning the new changes to js, But that snipet of code you have there looks pretty readable. How do you like ecma6?

Brian Jensen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brian Jensen
Treehouse Staff

I just started learning JS in April, so I pretty much only know the new syntax lol. I am lazy and really hate vanilla JS though. I much prefer jQuery.