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

Lilia Salazar
Lilia Salazar
4,728 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 >.<

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

1 Answer

Guillermo Gallo
Guillermo Gallo
Full Stack JavaScript Techdegree Student 8,490 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.