Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript jQuery Basics (2014) Creating a Mobile Drop Down Menu Setting a value

Setting a value in jQuery Basics

Once again, I'm totally lost...my code is probably not even close...can someone take a look and make suggestions...thanks!

btw, here's the question:

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.

Here's my code:

//Show Prompt Window and store value

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

//Select Input with the id of #fullName

$name.text(fullName);

//Insert value in to full name input

$name.val(fullName);

6 Answers

Neil Anuskiewicz
Neil Anuskiewicz
11,007 Points

I'm just starting the JQuery course too so I don't have a deep understanding but here's an answer I found that perhaps you could deconstruct? I hope this helps.

//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
$('#fullName').val(fullName);

/* $('#fullName') -> selects the input with this id.
   .val() -> JQuery method to get a value from an element or set the value if a value is passed.
   In this case, we set the value of the input to the value we get from the prompt.
*/

JQuery Basics is the worst tutorial that I have taken here on TreeHouse -by far (and up there with some of the worst tutorials the web has to offer - a copy & paste or copycat what the instructor does without explanation tutorial). It surprises me that they even have this up. There are much better JQuery courses on Udemy for $10 right now (which is what I've done to get through this part of the Fullstack JS track), but even free jquery tutorials on youtube, MDN, W3CSchools and even the JQuery website are better at teaching JQuery basics so you can come back and fight this section of the track (needlessly confusing and without explanation) and keep your fingers crossed that there aren't other poorly produced tutorials left in this track (or any other track that uses this section that you might taking). Hopefully, in the near-future, TreeHouse can put a proper or better conducted JQuery Basics tutorial up so people don't have to look and possibly pay elsewhere to learn a relatively simple subject.

I agree wholeheartedly! I've struggled with a lot of the coding concepts on here, as a newbie, but this course is not very educational. There's no explanation to why anything is done and we're expected to know many things esoterically, as if we weren't beginners or early in our coding education. I just have to try and watch the videos, snatch what info I can, fight the urge to dropkick my computer and/or punch a wall while violently sobbing, and then Google and copy and paste answers and code into my editor. Nice to know someone out there agrees and had the same problems.

I agree wholeheartedly! I've struggled with a lot of the coding concepts on here, as a newbie, but this course is not very educational. There's no explanation to why anything is done and we're expected to know many things esoterically, as if we weren't beginners or early in our coding education. I just have to try and watch the videos, snatch what info I can, fight the urge to dropkick my computer and/or punch a wall while violently sobbing, and then Google and copy and paste answers and code into my editor. Nice to know someone out there agrees and had the same problems.

I'm very happy to hear that I am not the only one thinking this. I've taken many treehouse courses before and all have been quite good and I felt I left the course with much more knowledge than when I started. I am half way through this course and still feel like I do not understand the general purpose of jQuery, and because of this, I am very slow to grasp the syntax.

Hope that someone at Treehouse takes a look at this thread and reevaluates their teaching method for jQuery.

Yixi Guan
Yixi Guan
7,927 Points

This one is confusing. There are two lines of comments, but you only need one line of code. I did it right the first time, but couldn't believe that's the right answer.

This is exactly how I feel. I sat here for at least 20 extra minutes confused when I completed this in one line, but went back to see how to do it in two.

Sajid Akhtar
Sajid Akhtar
3,081 Points

one line of code worked, as follows:

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

//Select Input with the id of #fullName
$("#fullName").val(fullName);
//Insert value in to full name input
Jeff Kinley
Jeff Kinley
21,207 Points

I have to agree. This is not my favorite course. Seems that something like jQuery is deserving of more.

hello and happy holidays, neil!

thank you for your answer...here's what worked:

//Show Prompt Window and store value

$('#fullName').val(fullName);

//Select Input with the id of #fullName

$('fullName').text(fullName);

//Insert value in to full name input

$('fullName').val(fullName);