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


Robert Kooyman
Robert Kooyman
4,927 Points

jquery not working

I am stuck! :) Please help when possible??

Challenge Task 1 of 1

A prompt dialog will open prompting for someone's full name. Use jQuery to follow the comments in code. First, select the correct input, and then set it's value to the fullName.

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

//Select Input with the id of #fullName var $select = $("<select></select>"); $("#fullName").append($select); //Insert value in to full name input

$("#fullName").each(function() { var $anchor = $(this); var $option = $("<option></option>");

$option.val($anchor.attr("")); $option.text($anchor.text()); $select.append($option);

ERROR MESSAGE: Bummer! If I typed "Andrew Chalkley" into the prompt, it didn't appear in the input!

1 Answer

Erik Nuber
Erik Nuber
20,629 Points
var fullName = prompt("What is your full name?");

$("#fullName").val(fullName); //Insert value in to full name input

The first part selects the ID fullName, the second part .val() is a setter in this case. It is setting the value of the fullName from the earlier prompt.

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

will become

<input id="fullName" name="fullName" value="INFO WILL BE HERE" disabled>