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

Why do none of the methods work? Is there a bug in the challenge?

var inputValue = document.getElementById('linkName'); //this should work. Tried querySelector as well and that didn't work.

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

Maher Wardak
Maher Wardak
4,595 Points

Hi Leo,

You need to retrieve the value of the input. So the code should look like this:

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

Thanks Maher! That works.