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

jough
jough
12,877 Points

code challenge help

I have a few questions about this code challenge:

  1. My code worked but is it the proper way to solve this challenge based on the topics covered in the previous 2 lessons?

  2. My struggle with these lessons and quizzes is not the concepts but the syntax. Did I miss the part where Gil talks about adding .value to the end of the querySelector? I feel like the quiz required concepts and syntax not covered in the videos.

  3. Why are the questions and answers to the code challenges not accessible from the code challenge step in the course? I have to either go back to the previous video or ahead to the next one to hopefully (not always) find Q&A pertaining to the code challenge.

app.js
let inputValue = document.querySelector('input').value;

let link = document.querySelector('a#link');
link.textContent = inputValue;
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

Adam Beer
Adam Beer
11,314 Points

This is my solution:

let inputValue = document.querySelector('#linkName').value;
let anchor = document.querySelector("#link");

anchor.innerText = inputValue;

I can not answer your last question. May not be able to see the solution.