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 trialSrdjan Cestic
6,855 PointsWhat's wrong in this challenge?
//Show Prompt Window and store value var fullName = prompt("What is your full name?");
//Select Input with the id of #fullName var $select = $fullName;
//Insert value in to full name input $fullName.val(prompt("What is your full name?"));
//Show Prompt Window and store value
var fullName = prompt("What is your full name?");
//Select Input with the id of #fullName
var $select = $fullName;
//Insert value in to full name input
$fullName.val(prompt("What is your full name?"));
<!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>
3 Answers
Luciano Bruzzoni
15,518 PointsHey there, You have a couple of things wrong with your javascript; Lets start from the top. The fullName var is assigned correctly, it now holds the prompt assigned, but you are not using it (more on that in a bit).
The $select variable is not selecting the id fullName correctly, it should be $("#fullName"). Ids are selected with the hashtag and classes with a period just like you would select them with CSS. Also, they go inside parenthesis and quotes.
So now that you have the id selected, instead of inserting the whole prompt again as the value, use the variable fullName that you created at the beginning. So it would be $select.val(fullName);
Hope that helped clear things up!
Srdjan Cestic
6,855 Points//Show Prompt Window and store value var $fullName = prompt("What is your full name?");
//Select Input with the id of #fullName var $select = $("#fullName");
//Insert value in to full name input $select.val(fullName);
Hi, this si my code and it isn't correct, where I go wrong now Luciano?
Luciano Bruzzoni
15,518 Pointsyou set your var name as $fullName but you are using fullName when calling it, missing the dollar sign. Ideally though, the reason for putting a $ on your variable names is when you are selecting an html element with jQuery, so for all other regular variables it's better to not use the dollar sign if that makes sense. It won't change anything what you decide to call it, but just for convention practices $ refers to that. like $select is selecting an html element with the jQuery method, so that's why they do it like that on the video!
Srdjan Cestic
6,855 PointsThanks for help! :)
Luciano Bruzzoni
15,518 Pointsno problem, glad to be of help!