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

Lilia Salazar
Lilia Salazar
7,623 Points

my solution was: document.querySelctor('.info').innerHTML = 'inputValue.value'; but is not ok, how to get the inputValue

this only add the text but not the value >.<

app.js
const inputValue = document.querySelector('#linkText').value;
document.querySelector('.info').innerHTML = 'sample text';
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

Guillermo Gallo
seal-mask
.a{fill-rule:evenodd;}techdegree
Guillermo Gallo
Full Stack JavaScript Techdegree Student 8,518 Points

Hi Lilia Salazar

You are very close. There are 2 things that need to be changed in your solution:

  1. The inputValue variable is already saving the value, so when you call the variable you do not need to use ".value" again. Just using the variable name should return the value from the input field.

  2. When you want to use the data (value) stored inside a variable you dont need to use quotes, just using the variable name without quotes is needed. If you wrap the variable name inside quotes you are telling the browser to print out the variable name not its value.

So something like this:

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

Hope this helps.