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 trial

JavaScript JavaScript and the DOM (Retiring) Making Changes to the DOM Changing Element Attributes

Perhaps someone can clarify the challenge question, as I suspect it is poorly worded

"Store the value of the input element with the id link in the variable inputValue. "

Okay, am I misunderstanding something? There is no input element with an id= link.

Is this actually meaning to say: "Store the value "link" into the id attribute of the input element? " (ie, change it)

If so, I'm not having success yet doing so, but I don't want to kill hours trying to solve a challenge that isn't even intended here.

Perhaps someone can offer another wording for this challenge that makes sense. I don't consider an anchor an input element. Am I wrong?

Hey Ed, as far as I remember, there's a typo: just find the correct id in the accompanying html and use it instead of link (don't remember what it is exactly)

8 Answers

The id named is indeed wrong. The challenge text is meant to read like this:

Store the value of the input element with the id linkName in the variable inputValue.

The HTML does have an <input> element with that id. The challenge wants you to target that element, pull out the value stored within it and assign it to the variable called inputValue.

Wish I saw this an hour ago. Thanks for clarifying this. Treehouse needs to proofread.

Thanks for saving me from a huge waste of time and undue agitation. My condolences to the rest that follow and don't see this question first.. :)

let inputValue = document.getElementById('linkName').value; << finally worked

Thanks!

This is what I put

let inputValue = document.getElementById("linkName");

But get THIS error:

You selected the element, but have not gotten the value.

Please help, thanks

You have the right element, as the input element clearly has the id linkName, but you didn't specify the value, accessed by adding ".value" to the end of your line of code. Your code should read... let inputValue=document.getElementById("linkName").value;

Guys, I got stuck with the second part of the challenge. Could someone please explain, how it should be done.

Challenge Task 2 of 2 Set the text content of the a tag to be the value stored in the variable inputValue.

that's my code from the first challenge so far: let inputValue = document.getElementById('linkName').value;

I have literally no clue how to proceed...

I am stuck on the second task as well.

Mine was:

const inputValue = document.getElementById('linkName').value;
document.getElementById('link').textContent = inputValue;

Mine:

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

I think I like Rod's more though.

The javascript and the dom course is awful. I haven't had so many problems with any of the other javascript courses