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 trialBill Ertle
9,286 PointsSetting 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
11,007 PointsI'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.
*/
Matthew Hartman
4,419 PointsJQuery 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.
Tyrel Kessinger
8,414 PointsI 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.
Tyrel Kessinger
8,414 PointsI 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.
Startup Shell
38,037 PointsI'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
7,927 PointsThis 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.
Patrick Abadilla
1,429 PointsThis 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
3,081 Pointsone 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
21,207 PointsI have to agree. This is not my favorite course. Seems that something like jQuery is deserving of more.
Bill Ertle
9,286 Pointshello 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);