jQuery Selectors
Selecting elements with jQuery
Basic Selectors
$('element') # select by tag
$('.class') # select by class
$('#id') # select by ID
$('*') # select all elements
Attribute Selectors
$('[name]') # has attribute
$('[name=value]') # attribute equals
$('[name^=value]') # starts with
$('[name$=value]') # ends with
$('[name*=value]') # contains
Hierarchy Selectors
$('parent child') # descendant
$('parent > child') # direct child
$('prev + next') # adjacent sibling
$('prev ~ siblings') # general siblings
Filter Selectors
$('li:first') # first element
$('li:last') # last element
$('li:even') # even elements
$('li:odd') # odd elements
$('li:eq(2)') # element at index
Content Filters
$('div:contains("text")') # contains text
$('div:empty') # empty elements
$('div:has(p)') # has descendant