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 Making Changes to the DOM Modifying Elements

Joseph Quintiliano
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Quintiliano
Front End Web Development Techdegree Graduate 14,338 Points

inputValue = document.querySelector('.info').textContent is wrong????

the second task made no sense, i wrote

inputValue = document.querySelector('.info').textContent; //this said i was wrong but these lessons never went over that it needs to read from left to write or right to left...i thought x=y and y=x was the same????

it only took the following code, why is that??

document.querySelector('.info').textContent = inputValue;

app.js
var inputValue = document.querySelector('input').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>

2 Answers

Steven Parker
Steven Parker
231,236 Points

The target of the assignment (the thing being changed) is always the term on the left of the = operator.

This wouldn't be covered in this specialty course, it would likely be in a preliminary course like JavaScript Basics.

Joseph Quintiliano
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Quintiliano
Front End Web Development Techdegree Graduate 14,338 Points

oh wait, i think its because im CHANGING the .textContent to inputValue, not changing inputValue to the textContent since there is no text content to begin with correct???