๐ ๊ธฐ๋ณธ ํํฐ ์ ํ์(Basic Filter)
์ ํ์ |
์์ |
์ค๋ช
|
:odd |
$("div:odd") |
ํ์ ๋ฒ์งธ์ ์์นํ ๋ฌธ์ ๊ฐ์ฒด๋ฅผ ์ ํํจ |
:even |
$("div:even") |
์ง์ ๋ฒ์งธ์ ์์นํ ๋ฌธ์ ๊ฐ์ฒด๋ฅผ ์ ํํจ |
:first |
$("div:first") |
์ฒซ ๋ฒ์งธ ์์นํ ๋ฌธ์ ๊ฐ์ฒด๋ฅผ ์ ํํจ |
:last |
$("div:last") |
๋ง์ง๋ง์ ์์นํ ๋ฌธ์ ๊ฐ์ฒด๋ฅผ ์ ํํจ |
์ ํ์ |
์์ |
์ค๋ช
|
:root |
$("div:root") |
document์ ๋ฃจํธ ์์ ์ ํ |
:target |
$("div:target") |
document์ URL์ flagment ์๋ณ์๋ก ์ง์ ๋ ๋์ ์์๋ฅผ ์ ํ |
:header |
$("div:header") |
h1, h2, h3 ๋ฑ๊ณผ ๊ฐ์ด ํค๋์ธ ๋ชจ๋ ์์๋ฅผ ์ ํ |
:empty |
$("div:empty") |
์์์ด ์๋ ๋ชจ๋ ์์(ํ
์คํธ ๋
ธ๋ ํฌํจ)๋ฅผ ์ ํ |
:parent |
$("div:parent") |
ํ๋ ์ด์์ ํ์ ๋
ธ๋(์์ ๋๋ ํ
์คํธ)๊ฐ ์๋ ๋ชจ๋ ์์๋ฅผ ์ ํ |
โ
๐ ํจ์ ํํฐ ์ ํ์(function Filter)
์ ํ์ |
์์ |
์ค๋ช
|
:eq(index) |
$("div:eq(1)") |
์ผ์นํ๋ ์งํฉ ๋ด์ ์ธ๋ฑ์ค n์ ์๋ ์์๋ฅผ ์ ํ |
:gt(index) |
$("div:gt(2)") |
์ผ์นํ๋ ์ธํธ ๋ด์ ์ธ๋ฑ์ค๋ณด๋ค ํฐ ์ธ๋ฑ์ค์์ ๋ชจ๋ ์์๋ฅผ ์ ํ |
:lang(language) |
$("div:lang(en-us)") |
์ง์ ๋ ์ธ์ด์ ๋ชจ๋ ์์๋ฅผ ์ ํ |
:lt(index) |
$("div:lt(4)") |
์ผ์นํ๋ ์งํฉ ๋ด์ ์ธ๋ฑ์ค๋ณด๋ค ์์ ์ธ๋ฑ์ค์์ ๋ชจ๋ ์์๋ฅผ ์ ํ |
:not(selector) |
$("div:not(:checked)") |
์ง์ ๋ ์ ํ์์ ์ผ์นํ์ง ์์ ๋ชจ๋ ์์๋ฅผ ์ ํ |
:contains(text) |
$("div:contains('Hello'") |
์ง์ ๋ ํ
์คํธ๋ฅผ ํฌํจํ๋ ๋ชจ๋ ์์๋ฅผ ์ ํ |
:has(selector) |
$("div:has(p)") |
์ง์ ํ ์ ํ์์ ์ผ์นํ๋ ์์๋ฅผ ํ๋ ์ด์ ํฌํจํ๋ ์์๋ฅผ ์ ํ |
:animated |
$("div:animated") |
์ ํ์๋ฅผ ์คํํ ๋ ์ ๋๋ฉ์ด์
์งํ ์ํ์ ์๋ ๋ชจ๋ ์์๋ฅผ ์ ํ ":not(:animated)" => ์ ๋๋ฉ์ด์
์ค์ด์ง ์์๊ฒ |
โ
๐ ์
๋ ฅ ์์ ํผ(Form) ํํฐ ์ ํ์
์ ํ์ |
์์ |
์ค๋ช
|
:button |
$(":button") |
input ํ๊ทธ์ค type ์์ฑ์ด button์ธ ๋ฌธ์ ๊ฐ์ฒด์ button ํ๊ทธ๋ฅผ ์ ํ |
:checkbox |
$(":checkbox") |
์ฒดํฌ๋ฐ์ค ์ ํ์ ๋ชจ๋ ์์ ์ ํ |
:checked |
$(":checked") |
์ฒดํฌ๋๊ฑฐ๋ ์ ํ๋ ๋ชจ๋ ์์์ ์ผ์นํ ์์ ์ ํ |
:disabled |
$(":disabled") |
๋นํ์ฑํ๋ ๋ชจ๋ ์์ ์ ํ |
:enabled |
$(":enabled") |
ํ์ฑํ๋ ๋ชจ๋ ์์ ์ ํ |
:file |
$(":file") |
ํ์ผ ์ ํ์ ๋ชจ๋ ์์๋ฅผ ์ ํ |
:focus |
$(":focus") |
ํ์ฌ ํฌ์ปค์ค๊ฐ ์๋ ์์ ์ ํ |
:image |
$(":image") |
์ด๋ฏธ์ง ์ ํ์ ๋ชจ๋ ์์ ์ ํ |
:input |
$(":input") |
๋ชจ๋ input, textarea, select, button ์์ ์ ํ |
:password |
$(":password") |
ํจ์ค์๋ ์ ํ์ ๋ชจ๋ ์์ ์ ํ |
:radio |
$(":radio") |
๋ผ๋์ค ์ ํ์ ๋ชจ๋ ์์ ์ ํ |
:reset |
$(":reset") |
reset ์ ํ์ ๋ชจ๋ ์์ ์ ํ |
:selected |
$(":selected") |
์ ํ๋ ๋ชจ๋ ์์ ์ ํ |
:submit |
$(":submit") |
submit ์ ํ์ ๋ชจ๋ ์์ ์ ํ |
:text |
$(":text") |
text ์ ํ์ ๋ชจ๋ input ์์ ์ ํ |
<select>
<option>์ฌ๊ณผ </option>
<option>๋ธ๊ธฐ </option>
<option>์๋ฐ </option>
<option>๋ฉ๋ก </option>
</select>
<script>
$('select > option:selected').val(); // select ๋ก ์ ํ๋ ๊ฐ์ด ์ฐพ๊ธฐ
</script>
์ถ์ฒ: https://inpa.tistory.com/entry/jQuery-๐-์ ์ด์ฟผ๋ฆฌ-์ ํ์-Selector-๐ฏ-์ ๋ฆฌ [Inpa Dev ๐จ๐ป:ํฐ์คํ ๋ฆฌ]
๐ ๊ฐ์์ฑ ํํฐ ์ ํ์ (Visibility Fileter)
์ ํ์ |
์์ |
์ค๋ช
|
:hidden |
$("div:hidden") |
hidden ๋ ๋ชจ๋ ์์ ์ ํ |
:visible |
$("div:visible") |
visible์ธ ๋ชจ๋ ์์ ์ ํ |