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 <p> elements

ID

Selects the element with ID myId

Class

Selects all elements with class myClass

Universal

Selects all elements

Group

Selects all<h1> and <p> elements

Advanced Selectors

Selector

Description

Example

$("p:first")

Selects the first<p> element

$("p:last")

Selects the last<p> element

$("li:even")

Selects even-numbered<li> elements

$("li:odd")

Selects odd-numbered<li> elements

$("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 attribute

$("[href='#']")

Selects elements with href="#"

$("[href^='https']")

hrefstarts withhttps

$("[href$='.com']")

hrefends with.com


Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.