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 trialWenhui (Sarah) Zhang
Full Stack JavaScript Techdegree Student 3,852 Pointsinput value
Ok... I'm not sure if I'm doing this wrong... Sorry if this is a simple question...
let inputValue = input.value;
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<link rel="stylesheet" href="style.css" />
<body>
<div id="content">
<label>Link Name:</label>
<input type="text" id="linkName">
<a id="link" href="https://teamtreehouse.com"></a>
</div>
<script src="app.js"></script>
</body>
</html>
2 Answers
Balazs Peak
46,160 PointsFirst, you have to select the corresponding HTML element, and then you can access its value. You've tried to access the element by simply using it's tagname. It doesn't work like that. You have to use a JS function for the purpose of selecting the HTML element, for example document.getElementById(), or document.querySelector(). These will create an object represenation of the HTML element in your JS code, which you can manipulate. Have fun ;)
Steven Parker
231,261 PointsYou have the right idea about getting the "value" property, but "input" is not currently defined in the JavaScript code. But the element you want has an ID property, so you could get to it using the "getElementById" method. This is demonstrated in this video which was recommended in the challenge as a refresher.
Balazs's suggestion of "querySelector" would also work, but I don' t think that has been introduced yet in the course.