JavaScript JavaScript and the DOM Making Changes to the DOM Modifying Elements

This question is really difficult for me to understand for some reason. Would love any explanation or hints.

Not sure how to use the id '#idName' and input.value in a querySelector statement together.

app.js
var inputValue = document.querySelector('#linkName value');
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>

1 Answer

rabin
seal-mask
.a{fill-rule:evenodd;}techdegree
rabin
Front End Web Development Techdegree Student 15,247 Points

Hey Jonathan Ambriz,

You were very close on the first part of the challenge, you simply need to store a value inside inputValue variable and you can do this by using a value property after selecting input element with the id of linkName. The value property sets or returns the value of the value attribute of a text field.

Here's the final version:

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

To understand how value property works, check out this website: https://www.w3schools.com/JSREF/prop_attr_value.asp

Hope this helps!