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 trialJanice Childers
18,958 PointsSetting value code challenge, jquery
I don't even know what this is asking? Can someone please rephrase what this is asking for? I have been trying to figure it out and am just blocked completely.
2 Answers
jobbol
Full Stack JavaScript Techdegree Student 17,885 PointsFirst it's asking you to find the DOM object. We typically save this to a variable so we can access it again.
var $name = $("#fullName");
Next the val function has two basic forms.
- Getting -- Takes the value out.
input = $num.val();
- Setting -- Changes the value to something else.
$num.val(input);
In this example you want to use #2, to set it to the value stored in fullName
.
See if you can put it together.
Janice Childers
18,958 PointsThanks, this helped me understand how val works. I find the explanations in the jquery api pretty unhelpful at this stage, but maybe it will make more sense as I go along.
Dana Wren
12,488 PointsI had problems with this one too, probably because the id name and the variable name were the same. It was much more simple than most of the things I was trying.
//Show Prompt Window and store value
var fullName = prompt("What is your full name?");
//Select Input with the id of #fullName
$name = $("#fullName");
//Insert value in to full name input
$name.val(fullName);
Janice Childers
18,958 PointsI never would have got this. I guess I didn't understand the val function after all. Still not sure I do.
Janice Childers
18,958 PointsJanice Childers
18,958 PointsI know this isn't right, but I'm stumped on what to do at all.