JAVASCRIPT & jQuery jQuery CSS μ νμ μ’ λ₯ - π κΈ°λ³Έ μ νμ μ νμ μμ μ€λͺ * $("*") λͺ¨λ μμλ₯Ό μ ν .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λ‘ μΌμΉνλ μμ 곡μ νκΈ° URL 볡μ¬μΉ΄μΉ΄μ€ν‘ 곡μ νμ΄μ€λΆ 곡μ μμ€ κ³΅μ κ²μκΈ κ΄λ¦¬ ꡬλ νκΈ°codena μ μμνμ λ³κ²½κΈμ§ Contents πκΈ°λ³Έμ νμ π μμμ νμ(child) π κ³μΈ΅μ νμ(Hierarchy) π μμ±μ νμ(Attribute) λΉμ μ΄ μ’μν λ§ν μ½ν μΈ jQuery μ μ© μ νμ μ’ λ₯ 2024.03.05 무ν λ‘€λ§ λ°°λ 2023.11.06 μ€ν¬λ‘€μ΄ λΈλΌμ°μ λμ λλ¬νμλ μ΄λ²€νΈμ£ΌκΈ° 2023.02.18 μ€ν¬λ‘€ λ΄λ¦¬λ©΄ λ€μ κΈ λΆλ¬μ€κΈ° (scroll μ΄λ²€νΈ) 2023.02.18 λκΈ 1 + μ΄μ λκΈ λ보기