Advertisement
Google Ad Slot: content-top
jQuery Selectors
jQuery selectors are used to "find" or "select" HTML elements, so you can apply actions to them — like hiding, showing, changing text, animating, and more.
jQuery selectors use the same syntax as CSS selectors, so if you know CSS, this will feel familiar!
All selectors in jQuery start with the dollar sign and parentheses: $().
Basic jQuery Selectors
Selector Type |
Description |
Example |
|---|---|---|
Element |
Selects all |
|
ID |
Selects the element with ID |
|
Class |
Selects all elements with class |
|
Universal |
Selects all elements |
|
Group |
Selects all |
Advanced Selectors
Selector |
Description |
Example |
|---|---|---|
$("p:first") |
Selects the first |
|
$("p:last") |
Selects the last |
|
$("li:even") |
Selects even-numbered |
|
$("li:odd") |
Selects odd-numbered |
|
$("ul li:first") |
Selects the first <li> element of the first <ul> |
|
$("ul li:first-child") |
Selects the first <li> element of every <ul> |
|
$("[href]") |
Selects elements with an |
|
$("[href='#']") |
Selects elements with |
|
$("[href^='https']") |
|
|
$("[href$='.com']") |
|