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

Hard for me to understand the question

I'm struggling a lot with this

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

Steven Parker
Steven Parker
182,269 Points

The "inputValue" that you acquired in task 1 one is the value you will be assigning, it goes on the right side of the assignment operator ("=").

On the left side, you'll need another selector function to get the element being assigned, from which you will then take the "textContent" attribute value.

Tylan Coleman
Tylan Coleman
Full Stack JavaScript Techdegree Student 3,947 Points

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

The question asks to store its VALUE into var inputValue. Make sure you use the value property described in the video at 4:30.

Steven Parker
Steven Parker
182,269 Points

The code shown here is not a correct solution. Did you try it in the challenge?