jQuery: More selectors

This entry is part 6 of 33 in the series jQuery Tutorial

For a beginner in jQuery programming, you will probably find that the 3 methods based on HTML elements, IDs and classes mentioned in the earlier post will be sufficed.

For a more thorough treatment of jQuery selectors, you can refer to this guide.

Nonetheless, we will go ahead and list down some common selectors.

$('*')Selects all elements
$('#demo_id')Selects elements with id='demo_id'
$('.demo_class')Selects all elements with class='demo_class'
$('p')All <p> elements
$('ul li:first')This selector gets only the first <li> element of the <ul>
$('li:not(.myclass)')Selects all elements matched by <li> that do not have class='myclass'.


Series Navigation<< jQuery: Selectors
jQuery: Events >>

Leave a comment

Leave a Reply