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 trialMing Chi Wong
2,909 PointsThe purpose of using $(':checked').length === 0.
I don't quite understand what $(':checked').length === 0. means?
2 Answers
Steven Parker
231,269 PointsThe $ is the abbreviation for jQuery, so this creates a jQuery object by selecting every element that has the status of "checked" (by using the pseudo-class selector). Then it accesses the length of that collection and looks to see if it is equal to 0, meaning the list is empty.
So essentially, it's a conditional expression asking "is there nothing checked on the page?".
Ming Chi Wong
2,909 PointsIs the :checked (pseudo-class selector) part relating to the anchor tags?
Steven Parker
231,269 PointsNo, see the comment I added to my answer.
Anastasios Poursaitedes
10,491 PointsNo It's not. The :checked selector matches all elements that are checked or selected, these include checkboxes, radio buttons and option from the select element.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsNo specific tag type is being selected here, but anchors don't have a "checked" attribute so they could not be selected. I believe only input tags (of type="checkbox" or "radio") can have this attribute.
If the question has been answered, you can mark it solved by choosing a "best answer".
And happy coding!