(새 문서: {| class='wikitable' !셀렉터 !예시 !설명 |- | *||$("*")||All elements |- | #id||$("#lastname")||The element with id="lastname" |- | .class||$(".intro")||All elements with class...) |
|||
3번째 줄: | 3번째 줄: | ||
!예시 | !예시 | ||
!설명 | !설명 | ||
|- | |||
|colspan='3' align='left' bgcolor='#FFEEEE'| '''id, class, tag로 선택''' | |||
|- | |- | ||
| *||$("*")||All elements | | *||$("*")||All elements | ||
15번째 줄: | 17번째 줄: | ||
|- | |- | ||
| el1,el2,el3||$("h1,div,p")||All <nowiki><h1></nowiki>, <nowiki><div></nowiki> and <nowiki><p></nowiki> elements | | el1,el2,el3||$("h1,div,p")||All <nowiki><h1></nowiki>, <nowiki><div></nowiki> and <nowiki><p></nowiki> elements | ||
|- | |||
|colspan='3' align='left' bgcolor='#FFEEEE'|'''처음, 마지막, 홀수, 짝수 선택''' | |||
|- | |- | ||
| :first||$("p:first")||The first <nowiki><p></nowiki> element | | :first||$("p:first")||The first <nowiki><p></nowiki> element | ||
23번째 줄: | 27번째 줄: | ||
|- | |- | ||
| :odd||$("tr:odd")||All odd <nowiki><tr></nowiki> elements | | :odd||$("tr:odd")||All odd <nowiki><tr></nowiki> elements | ||
|- | |||
|colspan='3' align='left' bgcolor='#FFEEEE'|'''자식, 타입에 따른 선택''' | |||
|- | |- | ||
| :first-child||$("p:first-child")||All <nowiki><p></nowiki> elements that are the first child of their parent | | :first-child||$("p:first-child")||All <nowiki><p></nowiki> elements that are the first child of their parent | ||
51번째 줄: | 57번째 줄: | ||
|- | |- | ||
| element ~ siblings||$("div ~ p")||All <nowiki><p></nowiki> elements that are siblings of a <nowiki><div></nowiki> element | | element ~ siblings||$("div ~ p")||All <nowiki><p></nowiki> elements that are siblings of a <nowiki><div></nowiki> element | ||
|- | |||
|colspan='3' align='left' bgcolor='#FFEEEE'|'''비교에 따른 선택''' | |||
|- | |- | ||
| :eq(index)||$("ul li:eq(3)")||The fourth element in a list (index starts at 0) | | :eq(index)||$("ul li:eq(3)")||The fourth element in a list (index starts at 0) | ||
59번째 줄: | 67번째 줄: | ||
|- | |- | ||
| :not(selector)||$("input:not(:empty)")||All input elements that are not empty | | :not(selector)||$("input:not(:empty)")||All input elements that are not empty | ||
|- | |||
|colspan='3' align='left' bgcolor='#FFEEEE'|'''태그 등에 따른 선택''' | |||
|- | |- | ||
| :header||$(":header")||All header elements <nowiki><h1></nowiki>, <nowiki><h2></nowiki> ... | | :header||$(":header")||All header elements <nowiki><h1></nowiki>, <nowiki><h2></nowiki> ... | ||
81번째 줄: | 91번째 줄: | ||
|- | |- | ||
| :lang(language)||$("p:lang(de)")||All <nowiki><p></nowiki> elements with a lang attribute value starting with "de" | | :lang(language)||$("p:lang(de)")||All <nowiki><p></nowiki> elements with a lang attribute value starting with "de" | ||
|- | |||
|colspan='3' align='left' bgcolor='#FFEEEE'|'''attribute에 따른 선택''' | |||
|- | |- | ||
| [attribute]||$("[href]")||All elements with a href attribute | | [attribute]||$("[href]")||All elements with a href attribute | ||
97번째 줄: | 109번째 줄: | ||
|- | |- | ||
| [attribute*=value]||$("[title*='hello']")||All elements with a title attribute value containing the string "hello" | | [attribute*=value]||$("[title*='hello']")||All elements with a title attribute value containing the string "hello" | ||
|- | |||
|colspan='3' align='left' bgcolor='#FFEEEE'|'''input 태그 선택''' | |||
|- | |- | ||
| :input||$(":input")||All input elements | | :input||$(":input")||All input elements |
2013년 11월 4일 (월) 07:29 판
셀렉터 | 예시 | 설명 |
---|---|---|
id, class, tag로 선택 | ||
* | $("*") | All elements |
#id | $("#lastname") | The element with id="lastname" |
.class | $(".intro") | All elements with class="intro" |
.class,.class | $(".intro,.demo") | All elements with the class "intro" or "demo" |
element | $("p") | All <p> elements |
el1,el2,el3 | $("h1,div,p") | All <h1>, <div> and <p> elements |
처음, 마지막, 홀수, 짝수 선택 | ||
:first | $("p:first") | The first <p> element |
:last | $("p:last") | The last <p> element |
:even | $("tr:even") | All even <tr> elements |
:odd | $("tr:odd") | All odd <tr> elements |
자식, 타입에 따른 선택 | ||
:first-child | $("p:first-child") | All <p> elements that are the first child of their parent |
:first-of-type | $("p:first-of-type") | All <p> elements that are the first <p> element of their parent |
:last-child | $("p:last-child") | All <p> elements that are the last child of their parent |
:last-of-type | $("p:last-of-type") | All <p> elements that are the last <p> element of their parent |
:nth-child(n) | $("p:nth-child(2)") | All <p> elements that are the 2nd child of their parent |
:nth-last-child(n) | $("p:nth-last-child(2)") | All <p> elements that are the 2nd child of their parent, counting from the last child |
:nth-of-type(n) | $("p:nth-of-type(2)") | All <p> elements that are the 2nd <p> element of their parent |
:nth-last-of-type(n) | $("p:nth-last-of-type(2)") | All <p> elements that are the 2nd <p> element of their parent, counting from the last child |
:only-child | $("p:only-child") | All <p> elements that are the only child of their parent |
:only-of-type | $("p:only-of-type") | All <p> elements that are the only child, of its type, of their parent |
parent > child | $("div > p") | All <p> elements that are a direct child of a <div> element |
parent descendant | $("div p") | All <p> elements that are descendants of a <div> element |
element + next | $("div + p") | The <p> element that are next to each <div> elements |
element ~ siblings | $("div ~ p") | All <p> elements that are siblings of a <div> element |
비교에 따른 선택 | ||
:eq(index) | $("ul li:eq(3)") | The fourth element in a list (index starts at 0) |
:gt(no) | $("ul li:gt(3)") | List elements with an index greater than 3 |
:lt(no) | $("ul li:lt(3)") | List elements with an index less than 3 |
:not(selector) | $("input:not(:empty)") | All input elements that are not empty |
태그 등에 따른 선택 | ||
:header | $(":header") | All header elements <h1>, <h2> ... |
:animated | $(":animated") | All animated elements |
:focus | $(":focus") | The element that currently has focus |
:contains(text) | $(":contains('Hello')") | All elements which contains the text "Hello" |
:has(selector) | $("div:has(p)") | All <div> elements that have a <p> element |
:empty | $(":empty") | All elements that are empty |
:parent | $(":parent") | All elements that are a parent of another element |
:hidden | $("p:hidden") | All hidden <p> elements |
:visible | $("table:visible") | All visible tables |
:root | $(":root") | The document’s root element |
:lang(language) | $("p:lang(de)") | All <p> elements with a lang attribute value starting with "de" |
attribute에 따른 선택 | ||
[attribute] | $("[href]") | All elements with a href attribute |
[attribute=value] | $("[href='default.htm']") | All elements with a href attribute value equal to "default.htm" |
[attribute!=value] | $("[href!='default.htm']") | All elements with a href attribute value not equal to "default.htm" |
[attribute$=value] | $("[href$='.jpg']") | All elements with a href attribute value ending with ".jpg" |
=value] | ='Tomorrow']") | All elements with a title attribute value equal to 'Tomorrow', or starting with 'Tomorrow' followed by a hyphen |
[attribute^=value] | $("[title^='Tom']") | All elements with a title attribute value starting with "Tom" |
[attribute~=value] | $("[title~='hello']") | All elements with a title attribute value containing the word "hello" |
[attribute*=value] | $("[title*='hello']") | All elements with a title attribute value containing the string "hello" |
input 태그 선택 | ||
:input | $(":input") | All input elements |
:text | $(":text") | All input elements with type="text" |
:password | $(":password") | All input elements with type="password" |
:radio | $(":radio") | All input elements with type="radio" |
:checkbox | $(":checkbox") | All input elements with type="checkbox" |
:submit | $(":submit") | All input elements with type="submit" |
:reset | $(":reset") | All input elements with type="reset" |
:button | $(":button") | All input elements with type="button" |
:image | $(":image") | All input elements with type="image" |
:file | $(":file") | All input elements with type="file" |
:enabled | $(":enabled") | All enabled input elements |
:disabled | $(":disabled") | All disabled input elements |
:selected | $(":selected") | All selected input elements |
:checked | $(":checked") | All checked input elements |
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.