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 trial2 Answers
Aydın Çağrı Dumlu
6,573 PointsNo it is not for removing elements. This method is used for select the elements that do not match the criteria are returned from the selection.
David Kanwisher
9,751 PointsLet's say you have 5 list items on your HTML page:
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li id="special">item 4</li>
<li>item 5</li>
If you were to type:
$("li")
it will select all 5 of your list items
so in turn if we were to say
$("li").css("font-weight","Bold");
it would give all 5 of our list items bold text
if we said
$("li").not("#special")
it would return 4 out of the 5 list items, but it would not include the one with the id of "special"
Using our previous example we can chain these to say:
$("li").not("#special").css("font-weight","Bold");
and now all EXCEPT number 4 have bold text