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

Brandon Robertson
Brandon Robertson
1,731 Points

Selecting element by id

I don't understand what I'm doing wrong in this exercise. I've done exactly what the video mentioned in the instructions

app.js
var inputValue = document.getElementById('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>

1 Answer

Dmitry Polyakov
Dmitry Polyakov
4,411 Points

You should grab the value of the element that you are selecting You were very close

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

Brandon Robertson
Brandon Robertson
1,731 Points

I swear I tried that but thank you!!