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

Angelica Islas
Angelica Islas
4,082 Points

How do I solve this problem?

Select the <input> element with the ID linkName and store its value in the variable inputValue.

var inputValue= "LinkName"
<!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

Hi Angelica,

a few things to do here before you pass this code challenge:

1) You have to first SELECT the id element, for example with document.getElementById(). But pay close attention to the exact writing of the id name. It is NOT "LinkName" but "linkName" (so it starts with a lowercase "l").

2) Once you selected the id you are asked to get the value of this element. This is easily done by just adding .value to the end of the selector you wrote.

Do you feel confident in selecting DOM elements yet? If not I would highly highly reccomend going over the basics of selecting DOM elements quite a few times (that's stage 2 of that course). It is really tough at the beginning and it is nearly impossible to grasp it all the first time. I remember I had a really tough time with the DOM concepts when I first learned it. And it's really valuable to repeat the basics of it quite a few times (until you feel comfortable).

Blessings from Berlin and happy java-scripting, Nils

PS: If my answer helped you or solved your issues, please upvote my answer and/or mark it as "Best answer" (so people browsing the community forum know your issue is solved)

Angelica Islas
Angelica Islas
4,082 Points

Nils Kriedner Thank you for your response here and on other posts I have made. I did know about names starting with lowercase. I should probably take a break from coding once I get tired. Lol Thank you again. I will referencing your answers as I continue on with my coding journey!

As a convention in JavaScript you best use so called "camelCase" in variable and function names.

Camel-case means the letter of the first name is lower case and every word after that starts with an uppercase letter, like myFullName or magicalFunctionThatMakesEverybodyHappy().