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 am confuse as to what the question is asking. i am typing document.getElementById('linkName');

document.getElementById('linkName');

app.js
var inputValue = document.querySelector("input");
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

Hi Carlos Gavilan,

Going off of the code you've provided, you're using document.querySelector() to grab the first input element in the DOM and assign the element to the variable inputValue.

What the challenge is asking you to do is to grab the input element with the id of "linkName" and store its value in the inputValue variable.

You can use document.getElementById() to do this, or you can use document.querySelector() to do this (there are additional ways you can do this as well, I'm sure). But grabbing the element is not enough, you have to all make sure that its value is assigned to the inputValue variable.

Hope this helps. Keep it up, Coder.

Daniel Jacoshenk
Daniel Jacoshenk
5,987 Points

Hi Carlos,

If you're using the .querySelector method then I believe you need to define the ID thats being select as such.

var inputValue = document.querySelector("#input");

Using the # selects an element by its ID.

However, you might notice that "input" is not actually the ID name for any element within the HTML code.

If you want to grab the element ID "linkName" and its value, I believe it can do so in one of two ways.

var inputValue = document.getElementById("linkName").value;

var inputValue = document.querySelector("#linkName").value;