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 trialVidar Maartensson
3,687 PointsGod DOM is hard... help(!)
Again, tried every possible outcome i can think of, both with the var += and the var = combinations... totally lost atmπ€
var inputValue=document.querySelector("input, #linkName").value;
inputValue += document.querySelector("input a, #link");
<!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>
1 Answer
Steven Parker
231,271 PointsPerhaps all you need is a few hints:
- ID's are unique, so when selecting something with an ID you need only the ID
- in task 2, you need to access the textContent of the element
- since task 2 is updating the document, the selector and property will be left of the assignment operator
- the value you retrieved in task 1 will be on the right of the assignment in task 2
Vidar Maartensson
3,687 PointsVidar Maartensson
3,687 Pointsdocument.querySelector('#link').textContent()+=inputValue was the best i could come up with, still not working... gr8 answer but im not quite understanding...
Steven Parker
231,271 PointsSteven Parker
231,271 PointsReally close now! Since "textContent" is a property and not a method, you won't need parentheses after the name. And the instructions call for a simple assignment ("=") instead of an addition assignment ("+=").
And just to be sure, you'll need to leave your task 1 code line as-is and add the new one after it.
Vidar Maartensson
3,687 PointsVidar Maartensson
3,687 PointsYou a hero man, thank you!!