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

Greg Schudel
Greg Schudel
4,090 Points

Getting errors on this one..

I can't get past this. I know it's stupid simple and even reviewed the previous example. Why does this not work? I'm sure the answer is stupid simple!!!!

let inputValue = clickedLink.value;
app.js
let 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>

3 Answers

Greg Schudel
Greg Schudel
4,090 Points

Finally passed this incredibly frustrating quiz, but after I got the code right, didn't let me review it to see what I did that was right!!!!!

I did something like this

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

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

And whenever I'm wrong with the second task it's persistently telling me my first task is wrong!!!!ugh!

Tobias Ångman
Tobias Ångman
7,194 Points

use innerHTML, see the first video of this section "Getting and Setting Text with textContent and innerHTML"

https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML

Hi, I'm not sure what is clickedLink, but you need to select input using one of the methods that you know and then get its value, for example, you can use the id of input tag that is: linkName, so with that being said it would be like: let inputValue = document.getElementById('linkName').value;

Greg Schudel
Greg Schudel
4,090 Points

Past the first one but lost on the second question:

Their question: Set the text content of the a tag to be the value stored in the variable inputValue.

My Answer:

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

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

also tried

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

a.textContent = inputValue;

also tried

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

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

getting lost and frustrated again