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

Chuck Comstock
Chuck Comstock
Full Stack JavaScript Techdegree Student 4,592 Points

Not sure what is happening here. I would appreciate help!

let aLink = document.querySelector('a#link'); aLink.textContext = inputValue.value;

app.js
let inputValue = document.querySelector('input#linkName').value;
let aLink = document.querySelector('a#link');
aLink.textContext = inputValue.value; 
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>

3 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 50,933 Points

inputValue already is the value so you don't need inputValue.value. Try task 2 in one line of code without the variable.

kevin curtis
kevin curtis
13,563 Points

Hey Chuck,

InputValue is already assigned as a variable in that challenge so you can remove the 'let,' it doesn't need to be assigned a second time.

Also, as Kris said, drop the .value from inputValue because you already got that value on the previous line. And lastly, you're also using textContext when it should be textContent.

So you should end up with something like this:

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

document.querySelector('a#link').textContent = inputValue; 
Chuck Comstock
Chuck Comstock
Full Stack JavaScript Techdegree Student 4,592 Points

Thanks guys! I found all this and fixed it. I couldn't figure out a way to remove my question. I appreciate your help!

kevin curtis
kevin curtis
13,563 Points

No worries Chuck. Leaving the question there could be beneficial to someone else having the same problem, so it's all good.