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!

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

Finding the value?

How do I find the value? I'm also having a tougher time learning Javascript, so any help would be nice.

var inputValue = document.getElementById('linkName');

linkName.addEventListener('click', () => {
  myHeading.style = 'linkName.value';           
<!DOCTYPE html>
        <title>DOM Manipulation</title>
    <link rel="stylesheet" href="style.css" />
        <div id="content">
            <label>Link Name:</label>
            <input type="text" id="linkName">
            <a id="link" href="https://teamtreehouse.com"></a>
        <script src="app.js"></script>

1 Answer

Karla Walker
.a{fill-rule:evenodd;}techdegree seal-36
Karla Walker
Full Stack JavaScript Techdegree Graduate 15,865 Points

Hi Alonzo! Looks like you saved the <input> element to inputValue so to get the value , just add .value to the end of document.getElementById('linkName') like so:

var inputValue = document.getElementById('linkName').value;

You can also save the element and value in separate variables in the case you need to use the <input> element somewhere else in your code:

var input = document.getElementById('linkName');
var inputValue = input.value;

Then, you can use the value by calling the variable name with no quotes wrapped around it. For example, say you want to update an <h1> element with the input value:

var h1 = document.querySelector('h1');
h1.textContent = inputValue;

I'm not sure if the rest of your JavaScript works based on this short snippet but I hope this helps you out some!