Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Mitchell Wintrow
Mitchell Wintrow
4,380 Points

How do I solve this text content challenge? I don't even understand what it's asking of me... The video doesn't help...

What is this challenge even asking me to do? I rewatched the video before it 4 times, and found nothing in it that helps me with this particular challenge. I've tried all kinds of different ways to do this, but I've had no luck whatsoever and the challenge doesn't really provide useful information about what I'm doing wrong. I get that it's a challenge, but isn't the point to learn, and how do I learn when it doesn't guide me through what I'm doing wrong? The video doesn't say and neither does the feedback, so I'm hoping the community on here will be able to help me! It barely touched on 'textContent' and didn't explain how to do what this challenge is asking for. I'm sure I'll probably feel stupid when I get the solution, but seriously I've been working on this for an hour and a half and it's really frustrating because so far everything else in this course has been incredible and I've been able to follow along and figure it out. I have never had this much trouble with any other challenges in this entire course so far, I think this one just doesn't explain what is being asked well enough and the video doesn't explain how to do it clearly, but it could be that I'm missing something too. Thanks for your help!

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

document.querySelector('p .info').textContent = myInput.value
index.html
<!DOCTYPE html>
<html>
    <head>
      <title>DOM Manipulation</title>
    </head>
    <link rel="stylesheet" href="style.css" />
    <body>
      <div id="content">
        <label for="linkText">Link Text:</label>
        <input type="text" id="linkText" value="sample text">
        <p class="info"></p>
      </div>
    <script src="app.js"></script>
  </body>
</html>

1 Answer

Joseph Yhu
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Yhu
PHP Development Techdegree Graduate 48,463 Points

You almost got it correct; you just have to remove the p and the space from document.querySelector('p .info').textContent = myInput.value;. You don't need it since there's only one element with the info class.

Mitchell Wintrow
Mitchell Wintrow
4,380 Points

Thank you so much Joseph!!! You have been a huge help and you're correct, it definitely worked. I knew I would feel stupid afterward haha, it was such a simple fix. It's hilarious much much trouble such small things in programming can give us.