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

Neil Martin Orbase
Neil Martin Orbase
2,914 Points

Assistance please! Not sure if I'm understand how to select text input correctly...

I've been stuck on this problem for almost 30 mins... rewatched the video that was suggested, followed the suggestion... and still, nothing... I even tried this: var inputValue = document.querySelector('linkName');

And that still fails =(

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

Daniel Jong
Daniel Jong
9,915 Points

Hi, you have to use .value to get the value from the text input

The code would look like this:

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

Hope this helps!