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

Mohamed Refaat
Mohamed Refaat
6,693 Points

I can't solve this

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 its value to the fullName.

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

//Select Input with the id of #fullName

//Insert value in to full name input
index.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<label for="fullName">Full Name</label><input id="fullName" name="fullName" value="" disabled>
<script src="//code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I would prefer to see some code as a "good faith" attempt. This would allow us to see where exactly you're going wrong or what you haven't understood. I'm of the opinion that this will result in a better overall learning opportunity for you! Tips on how to post your code can be found by clicking on the Markdown Cheatsheet link at the bottom of the "Add an Answer" section. :sparkles:

1 Answer

Steven Parker
Steven Parker
229,745 Points

:point_right: Here's a few generic hints.

I agree that you should "give it your best try" before receiving explicit assistance, but here's a couple of hints that might help you get started:

  • while the comments imply that the challenge requires two lines, it can easily be done with one
  • when selecting an element by ID, remember to prefix a pound-sign (#) to the ID name
  • a handy jQuery shortcut for getting or setting a value attribute is the val method
  • if you're totally lost, you might find this video helpful: Selecting Page Elements with jQuery

The video mentioned above comes from the short Introduction to jQuery course, which you might also enjoy.