π κΈ°λ³Έ μ νμ
| μ νμ |
μμ |
μ€λͺ
|
| * |
$("*") |
λͺ¨λ μμλ₯Ό μ ν |
| .class |
$(".class") |
μ§μ ν ν΄λμ€λ₯Ό κ°μ§λ λͺ¨λ μμλ₯Ό μ ν |
| element |
$("element") |
μ§μ λ νκ·Έλͺ
μ κ°μ§λ λͺ¨λ μμλ₯Ό μ ν |
| #id |
$("#id") |
μ§μ ν ID μμ±μ κ°μ§λ νλμ μμλ₯Ό μ ν |
| , |
$("selector1, selecotr2") |
λͺ¨λ μ§μ ν μ νμλ€μ κ²°κ³Όλ€μ κ²°ν©νμ¬ μ ν |
π μμ μ νμ (child)
| μ νμ |
μμ |
μ€λͺ
|
| :first-child |
$("div:first-child") |
λΆλͺ¨μ 첫 λ²μ§Έ μμμΈ λͺ¨λ μμλ₯Ό μ ν |
| :first-of-type |
$("div:first-of-type") |
λμΌν μμ μ΄λ¦μ νμ μ€ μ²« λ²μ§Έ μμλ₯Ό λͺ¨λ μ ν |
| :last-child |
$("div:last-child") |
λΆλͺ¨μ λ§μ§λ§ νμ μμμΈ λͺ¨λ μμλ₯Ό μ ν |
| :last-of-type |
$("div:last-of-type") |
λμΌν name μμμ νμ μ€ λ§μ§λ§ μμμΈ λͺ¨λ μμλ₯Ό μ ν |
| :nth-child(index/even/odd/equation) |
$("div:nth-child(2)") |
λΆλͺ¨μ n λ²μ§Έ μμμΈ λͺ¨λ μμλ₯Ό μ ν |
| :nth-last-child(index/even/odd/equation) |
$("div:last-child(2)") |
λ§μ§λ§ μμμμ 첫 λ²μ§Έ μμκΉμ§ κ³μ°νμ¬ λΆλͺ¨μ n λ²μ§Έ μμμΈ λͺ¨λ μμλ₯Ό μ ν |
| :nth-last-of-type(index/even/odd/equation) |
$("div:nth-last-of-type(2)") |
λ§μ§λ§ μμλΆν° 첫 λ²μ§Έ μμκΉμ§ κ°μ name μμλ₯Ό κ°μ§ νμ μ κ΄λ ¨νμ¬ λΆλͺ¨μ n λ²μ§Έ μμμΈ λͺ¨λ μμ μ ν |
| :nth-of-type(index/even/odd/equation) |
$("div:nth-of-type(2)") |
λμΌν name μμλ₯Ό κ°λ νμ μ κ΄λ ¨νμ¬ λΆλͺ¨μ nλ²μ§Έ μμμΈ λͺ¨λ μμ μ ν |
| :only-child |
$("div:only-child") |
λΆλͺ¨μ μ μΌν μμμΈ λͺ¨λ μμλ₯Ό μ ν |
| :only-of-type |
$("div:only-of-type") |
λμΌν name μμλ₯Ό κ°λ νμ λ
Έλκ° μλ λͺ¨λ μμ μ ν |
β
π κ³μΈ΅ μ νμ (Hierarchy)
| μ νμ |
μμ |
μ€λͺ
|
| > :: parent > child |
$("ul > li") |
"parent"λ‘ μ§μ λ μμμ "child"λ‘ μ§μ λ λͺ¨λ μ§μ μμ μμ μ ν |
| (곡백) :: ancestor descendant |
$("form input") |
μ§μ λ μ‘°μμ μμμΈ λͺ¨λ μμ μ ν |
| + :: prev + next |
$("label+input") |
νμ "prev"κ° λ°λ‘ μμ μ€λ "next"μ μΌμΉνλ λ€μ μμ λͺ¨λ μ ν |
| ~ :: prev~siblings |
$("#prev~div") |
"prev"μμ λ€μμ μ€λ λͺ¨λ νμ μμλ₯Ό μ ννκ³ , μμ μμκ° κ°μΌλ©° νν°λ§ "siblings" μ νμμ μΌμΉνλ μμ |
β
π μμ± μ νμ (Attribute)
| μ νμ |
μμ |
μ€λͺ
|
| [attribute|='value'] |
$("[name|=apple]") |
μμ± nameκ°μ΄ appleμ΄κ±°λ, apple- μΌλ‘ μμνλ μμ |
| [attribute*='value'] |
$("[name*=apple]") |
μμ± nameκ°μ΄ appleμ΄λ λ¨μ΄λ₯Ό ν¬ν¨νλ μμ (μ΄λ μμΉλ ) |
| [attribute~='value'] |
$("[name~=apple]") |
μμ± nameκ°μ΄ appleμ΄κ±°λ apple 곡백 / 곡백 apple μΌλ‘ ꡬλΆλ λ¨μ΄λ₯Ό ν¬ν¨νλ μμ |
| [attribute$='value'] |
$("[name$=apple]") |
μμ± nameκ°μ΄ appleμ΄κ±°λ appleλ‘ μ νν λλλ κ°μΈ μμ λΉκ΅λ λμ λ¬Έμλ₯Ό ꡬλΆν¨. |
| [attribute='value'] |
$("[name=apple]") |
μμ± nameκ°μ΄ μ νν appleμΈ μμ |
| [attribute!='value'] |
$("[name!=apple]") |
μμ± nameκ°μ΄ appleμ μμ κ°μ§ μκ±°λ, apple μ΄μΈμ κ°μ κ°μ§ μλ μμ |
| [attribute^='value'] |
$("[name^=apple]") |
μμ± nameκ°μ΄ appleμ΄κ±°λ, appleλ‘ μ νν μμνλ μμ |
| [attribute] |
$("[name]") |
μμ± nameμ κ°κ³ μλ μμ |
| [attribute='value'][attribute2='value2'] |
$("[name=apple][name2=banana]") |
κ° μμ± μ νμλ€μ΄ andλ‘ μΌμΉνλ μμ |
μμ€ν κ³΅κ° κ°μ¬ν©λλ€
ν¬μ€ν
μ£Όμλ₯Ό 볡μ¬νμ΅λλ€
μ΄ κΈμ΄ λμμ΄ λμλ€λ©΄ κ³΅κ° λΆνλ립λλ€.