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

Gabriel Song
Gabriel Song
3,697 Points

Quiz does not evaluate my answer correctly, but can't tell what wrong!

The question is: Select the <input> element with the ID linkName and store its value in the variable inputValue.

I answered with:

const inputValue = document.querySelector('input#linkName');

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

Dmitry Polyakov
Dmitry Polyakov
4,411 Points

This assignment is asking to save a value, so it should be

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

Dmitry Polyakov
Dmitry Polyakov
4,411 Points

You should do it this way

const inputValue = document.querySelector('#linkName');