Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript jQuery Basics (2014) Creating a Mobile Drop Down Menu Setting a value

What is the point of the step to select #fullName?

It doesn't do anything, right? Couldn't you eliminate that line? This took me a little longer than I was expecting because I was trying to think if there was some other answer I was missing.

2 Answers

0yzh 󠀠
0yzh 󠀠
17,276 Points

Hey Christian,

The step to select the element with the id = #fullName is so you can take the value that the user entered into the prompt("What is your full name?"), and display it back on the page. In this case, the input element with the id of #fullName.

example

//Show Prompt Window and store value
var fullName = prompt("What is your full name?");

//Select Input with the id of #fullName
$('#fullName').val(fullName);
//Insert value in to full name input

Ok, but then you didn't put anything under //Insert value in to full name input because you did that in one step, right? That is, you did both Select input and Insert value on the same line.

0yzh 󠀠
0yzh 󠀠
17,276 Points

Yeah all in one step. You can select it and set the value in one line since jQuery methods are chainable. Did you answer it a little differently? I think the bottom comment makes it a little confusing since it looks like you have to do two separate steps.

Right, that was exactly my confusion. It seemed like there was a step I was missing. Thanks!

Hi Christian, This challenge is having you select the #fullName input so you can replace it's value with the full name collected via the prompt.