Jquery Selectors With Example

Jquery Selectors allows to select,modify,remove html elements

September 14, 2020

1) ID Selector (Query an element with provided ID)

$("#elementID")

2) Class Selector (Query an element with provided class name)

$(".classname")

3) Element Selector (Query an element with provided element type)

$("div")
$("section")
$("p")

4) Attribute Selector (Query an element with provided Attribute)

$("div[class='anyclass']")
$("#elementid[type='text']")
$("p[id='anyid']")

5) Attribute Selector (Query an element with provided Attribute)

$("div[class='anyclass']")
$("#elementid[type='text']")
$("p[id='anyid']")

6) First Element Selector (Query First element)

$("h2:first")
$(".elementclass:first")

7) Last Element Selector (Query Last element)

$("h2:last")
$(".elementclass:last")

Post Comments(0)

Leave a reply

Will not be displayed in comment box .

Loading...