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 jQuery Basics (2014) Creating a Mobile Drop Down Menu Setting a value

Jade Hudson
Jade Hudson
6,859 Points

I've been stuck on this one for about an hour can anybody explain what this one is all about? And help me?

Any help would be most appreciated.

What is this question all about.

Post the code you have done so far and let's take a look at it.

1 Answer

It looks like it is asking for you to use the prompt value and assign it to a variable. Then after that you need to select the input you want to add the value to, which you can simply use a variable which it is assigned to. Finally, you need to use the val() function to add the value of the first variable (fullName) to it. This is what I did:

//Show Prompt Window and store value - Takes the value from the prompt and assigns it to fullName
var fullName = prompt("What is your full name?");

//Select Input with the id of #fullName - assigns the dom object of the input with the id of #fullName to the input //variable

var input = $('#fullName');

//Insert value in to full name input - uses the val() function to change the value of $('fullName') to the input
input.val(fullName);             
LaVaughn Haynes
LaVaughn Haynes
12,397 Points

Luke is correct.

You are getting the value returned from the prompt. For example: var fullName = "Jade";

var fullName = prompt("What is your full name?");

Then selecting the input (the "fullName" text field) from the form with jQuery $('#fullName')

<input id="fullName" name="fullName" value="" disabled>

...and adding the value to it $('#fullName').val(fullName)

<input id="fullName" name="fullName" value="Jade" disabled>