programming/JS

[jQuery] selector

솧이 2022. 8. 25. 22:46
https://www.w3schools.com/jquery/trysel.asp
 
$("#Lastname")
$(".intro")
$(".intro, #Lastname") : .intro와 #lastname
$("h1")
$("h1, p")
$("p:first") : p의 첫번째 element
$("p:last")
$("tr:even") : 홀수행 
$("tr:odd") : 짝수행
$("p:first-child")
$("p:first-of-type")
$("p:last-child")
$("p:last-of-type")
$("li:nth-child(1)")
$("li:nth-last-child(1)")
$("li:nth-of-type(2)")
$("li:nth-last-of-type(2)")
$("b:only-child")
$("h3:only-of-type")
$("div > p") : div 안 p
$("div p") : div 안 모든 p
$("ul + p") : ul 다음 p
$("ul ~ table")
$("ul li:eq(0)")
$("ul li:gt(0)")
$("ul li:lt(2)")
$(":header")
$(":header:not(h1)")
$(":animated")
$(":focus")
$(":contains(Duck)")
$("div:has(p)")
$(":empty")
$(":parent")
$("p:hidden")
$("table:visible")
$(":root")
$("p:lang(it)")
$("[id]")
$("[id=my-Address]")
$("p[id!=my-Address]")
$("[id$=ess]")
$("[id|=my]")
$("[id^=L]")
$("[title~=beautiful]")
$("[id*=s]")
$(":input")
$(":text")
$(":password")
$(":radio")
$(":checkbox")
$(":submit")
$(":reset")
$(":button")
$(":image")
$(":file")
$(":enabled")
$(":disabled")
$(":selected")
$(":checked")
$("*")