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
Gina Sabori
8,664 PointsIntro to Jquery Manipulate Elements & Add Behavior Challenge task 1
I"m having trouble even understanding what this question is asking of me,, so I can only post the question. Not understanding the language here yet, so can someone break down the question for me and try to explain what its asking of me? "What does it mean by "call show method"? Honestly have no clue what I'm supposed to do here, can someone clue me in? Maybe its just my learning style, but the videos aren't giving me enough to go on......................................................................................................Call show method on the jQuery selected element with the class of 'error'. $(".error"); $("a");
2 Answers
Bryan Heredia
7,777 PointsI'm new to jQuery too and if I'm not mistaken when it asks you to call the show method it is asking you to call the method that will make the element visible, therefore I think that the element is hidden with the hide method wich is simply $("elementname").hide() or other methods that actually hide the element. So I believe that they are asking you to do the following $("elementname").show() that's how I understand it, I hope this helped and if not so sorry but check out the jQuery documentation.
Tom Mertz
15,254 PointsHi, an element is any HTML tag, such as
<a> <p> <ul> <h1>
So when they say "Element" you should immediately think of those. A class in HTML is an attribute that you put inside those tags. (Attribute just means something you put inside HTML tags). So
<a class="error">
makes an anchor element that has a class of error.
In jQuery, you can select elements
<a> <p> <h1>
by typing $("a") or $("p") etc. This tells jQuery that you want to do something to specifically those elements (a or p).
Once you have selected them, you need to tell jQuery what to do with them. $("a") just tells jQuery to look at all the anchor elements. By calling a method you actually tell jQuery what to do to those elements.
To call a method you use the dot operator . followed by the method, in this case show(). So when you type $("a").show() you are telling jQuery to look at all the
<a>
elements and call the method "show()" on all of those anchor elements.
The cool thing about jQuery is it lets us look at elements based on their class, too. So if we have an anchor element
<a class="error">
instead of telling jQuery to look for ALL anchor elements, we can tell it to just look for the ones that have a class of "error" To do this you would type: $(".error")
Now, once again jQuery is just looking at all the elements with class "error", so now you have to tell jQuery what to do with those classes. So you call the show() method on them with the dot operator! $(".error").show() will show all of the HTML elements with the "error" class.
Good luck!