Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Making Changes to the DOM Modifying Elements

Mahfuzur Rahman
Mahfuzur Rahman
3,204 Points

difficulty in understanding and passing the second task

let inputValue=document.getElementById('linkName');

let aTag=document.getElementById('link'); inputValue=aTag;

// I understand that here I am replacing the inputValue with the aTag.

app.js
let inputValue=document.getElementById('link').value;

//let aTag=document.getElementById('link').value;
//inputValue=aTag;
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

Matthew Long
Matthew Long
28,407 Points

Looks like you've almost got the first challenge. However, you're not selecting the input element, you're selecting the anchor element. The ID associated with the input element is linkName, not link.

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

The second challenge wants you to use the value from the input element that you selected and stored in the variable inputValue. Make that the text, or innerHTML of the anchor tag that you had previously selected in your original solution attempt.

document.getElementById('link').innerHTML = inputValue;