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.
Lilia Salazar4,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> <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>
You are very close. There are 2 things that need to be changed in your solution:
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.
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.