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

Zachary Allen
Zachary Allen
2,172 Points

Need Help with simple jQuery

I can't figure out how to write the .click listener so that it will work, here is what i have so far.

Add click listener to the link with an anonymous function containing no code to each link.

$(".error").show(); $("a").before("<span>This is a link: </span>")

Any help would be appreciated. Thanks

9 Answers

Danielle Phipps
Danielle Phipps
2,861 Points

I really wish they would lay it out better. I have never even attempted to use jquery before and I haven't been able to correctly answer a single code challenge. I kept having to look up the answer to move on.

Anne Korteweg
Anne Korteweg
3,536 Points

i have the same problem... it's just not very well explained in the video's... the code challenges are too difficult if you have zero jQuery knowledge...

Jim Ashley
Jim Ashley
3,935 Points

Oh thank God. It's not just me! I've just gone from HTML to CSS..... to feeling like I've not picked up anything. Back to the Foundations for me then...

lol, wow me too, i hate having to look it up for help. i feel like am not learning

i toook the java script foundations, tried very hard to understand it, but i feel totall lost sorry threehouse

I have the same issue with this not being explained clearly. Up until now I've enjoyed learning with Treehouse but if this carries on so I will be having second thoughts about paying for another month. I wonder if anybody from Treehouse is reading this stuff at all as this comment is to a post that was posted 8 months ago and it looks like that nothing has been done to answer the problem or problems.

I am with all of you. When I read the challenge "Add click listener to the link with an anonymous function containing no code to each link." All I could think was, what the _____ does the even mean?

Here you go, it was driving me nuts too, it's like the deeper we go the less is laid out in the videos as they pertain to the challenge. I guess it's good because it forces you to apply it but as beginners it's tough.

$(".error").show();
$("a").before('<span>This is a link: </span>').click(function(){});

I haven't done this challenge, but a click listener looks like this:

$("a").click(function() {

});

You could chain it to your existing link, like so:

$("a").before("This is a link: ").click(function() {

});
Michael Walker
Michael Walker
12,466 Points

Actually James, I started at Code Academy learning HTML, CSS and JavaScript before I came to this site. Code academy is a free site for learning code and it's an ideal place to start. They were the ones that recommended Treehouse after I completed those courses for more hands on learning. The learning videos for HTML, CSS and JavaScript are excellent here since you actually type the code as the video plays. When it's time to take the test, you simply review at the code you've already done and follow the same syntax.

I was disappointed to say the least when I found that the interaction for jQuery is nothing like that. You get a minute watching basic selectors fly past the screen at 100 miles an hour and then you are expected to remember the syntax for review and a quiz. It just makes no sense. I have not passed one test without having to look it up at another source.

The users in this post are right. If we are paying for this service, it should be a one-stop shop and shouldn't have to go to other sources just to get a BASIC understanding of the code. Also the Introduction to Programming course was the opposite, albeit just as frustrating, experience. After having learned the basics at Code Academy, it went through such a dismal pace I was falling asleep. One course is way too slow, the other moves way too fast. A little more balance is called for here, not a reference to learn code elsewhere!

You are not alone guys, it's not you, it's the site!

James Barnett
James Barnett
39,199 Points

Danielle Phipps - Maybe work through the Intro to Programming and JavaScript Foundations courses before you try out Build an Interactive Website course.

You may also want to check out the JQuery & JavaScript courses over of Codecademy first.

Anne Korteweg
Anne Korteweg
3,536 Points

I actually did follow Intro to Programming and JavaScript Foundations before I started with jQuery... but for me it's too difficult and not a good follow up on the JS course.

I also think it's not the way to go if I have to go to CodeAcademy first even though if I have a paid memebership at Treehouse...

James Barnett
James Barnett
39,199 Points

Anne Korteweg -

I also noticed that you seemed to have skipped over several foundational courses including as the very important pre-req of the CSS Foundations course. You should follow the Learn JavaScript & JQuery learning adventure.


I also think it's not the way to go if I have to go to CodeAcademy first even though if I have a paid memebership at Treehouse...

I don't work for Treehouse, I'm just a user that's very active on the forums, here's my 2 cents.

My view of learning to program is that you can't learn everything from one source, so consulting multiple sources helps you to understand the subject matter. Some sources favor a Project-first approach and some favor a Fundamentals-first approach with lots of small exercises. I personally favor the later.


There are several resources to learn JavaScript & JQuery online that are free, these are my favorites listed in viewing order.

@Ian Thank you! This was driving me nuts. I actually pasted the challenge question in Google and found this link, lol. Coming straight to the forum next time!

Michael Norton
Michael Norton
6,739 Points

Treehouse is not very conducive for learning. The video's assume your already an expert and there is no need to actually explain anything. And don't just say to take the "foundation classes" because that is NOT the case for most IMHO. On top of that many of the Code Challenges don't work properly which causes great frustration. I am canceling my subscription, and going to CodeSchool. Maybe their learning environment is more conducive to actual learning, and not constant frustration as is the case with Treehouse. If you don't believe me, check the forums out. Almost everyone has issues with understanding what the videos are saying even after watching them over and over. I constantly have to go to other online sources to actually answer most of the code challenges, and that should not be the case. Bye Treehouse, hope you improve your MOD, because your current MOD just creates great frustration and discouragement to the students.

Jeremy Frimond
Jeremy Frimond
14,470 Points

This is introduction to Jquery right? ...soooo where's the introduction??

Haha perfect! This jQuery section on Treehouse is garbage! I went to try.jquery.com and they have a FREE 3 hour video/challenge course on jQuery. I'm trying to get into a coding school and thought Treehouse was perfect after going through Intro to Programming, but this is unacceptable. I also spent hours and hours on codeacademy.com to learn javascript basics before Treehouse.

carter huff
seal-mask
.a{fill-rule:evenodd;}techdegree
carter huff
Full Stack JavaScript Techdegree Student 9,043 Points

I think this is a rather good approach, I don't mean to say this to cause any controversy. However, one should have a sound foundation in HTML and CSS before starting js or jq. In regards to the JQ course, it's seemingly designed to build on the knowledge one should have obtained by doing the previous videos or if you are taking this as a stand alone, a sound foundation in HTML and CSS is very important. He does not need to explain the details because at this point you have a good grasp of the type of logic used in HTML and CSS and hopefully some JS. It would not help us if he held our hand through the explanations because much of the logic used has already been taught. It is difficult, but learning to ask questions and look up answers will dramatically improve your ability to write code. We should be struggling with nearly every problem, typing in what we think is the answer then typing in variations of the possible answer by using our own logic. If this fails then one should research and come back, reading is critically important to the process of learning, he can't tell us everything.

$("a").before("<span>This is a link: </span>").click(function) { }); This is the answer if anybody needs it, try to think about what exactly this is doing. Also, the {} () ; placement is a pain and always something that is troubling for me, be very mindful of what it means when you add these in and where you add them in. I hope this helps people, I don't mean any negative remarks, I just think he wants us to use our knowledge base as well as our tools to solve these problems.

John Yzaguirre
John Yzaguirre
22,025 Points

Well this is the most recent post here but I have to re-say it. This is NOT a basics course. I went searching online to find a real basic jquery tutorial and it was a FREE article that explained jquery using a webpage that had 2 elements of TEXT. They showed very basic concepts of what jquery does. JavaScript is also shown to provide a comparison of how many lines of code you do not have to do. After taking JavaScript there should be way more in depth analysis of the code you DO understand (JavaScript) VS the code you are trying to LEARN (jquery). And treehouse has great little animation segments(thanks Dave from javascript!) that explain what is going on...but in this course you get one little cartoon at the very beginning followed by nothing but videos of the teacher plowing through code like it's his actual work and it needs to get handed in ASAP.
I took all the pre reqs for this on my track and I am completely utterly lost every step of the way. I am just blowing through this and i'll probably come back to it when i've taken a real basics course as this is most certainly an intermediate lesson!!!!

You get what you pay for people. I am happy I don't have to pay $400 to sit in a class and i have to say OVERALL i am very happy with treehouse and what they are providing for $25 a month. Hopefully this criticism might bring about a REAL introduction to BASIC jquery and rename this course INTERMEDIATE jquery.