체크 박스 옵션이 많아져서 원하는 걸 찾기 어려울 때 사용하시면 됩니다.
몇 번 언급한 적이 있는 CoffeeScript를 사용했습니다.
[index.html]
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Checkbox Filter</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js" type="text/javascript"></script>
<script src="application.coffee" type="text/coffeescript"></script>
</head>
<body>
<div id="container">
<form method="post" action="/">
<label for="input-filter">Filter:</label>
<input id="input-filter" type="text" name="filter" />
<ul>
<li>
<input id="id_1" type="checkbox" name="ids[]" value="1" />
<label for="id_1">#1 - AA</label>
</li>
<li>
<input id="id_2" type="checkbox" name="ids[]" value="2" />
<label for="id_2">#2 - BA</label>
</li>
<li>
<input id="id_3" type="checkbox" name="ids[]" value="3" />
<label for="id_3">#3 - AB</label>
</li>
<li>
<input id="id_4" type="checkbox" name="ids[]" value="4" />
<label for="id_4">#4 - BB</label>
</li>
<li>
<input id="id_5" type="checkbox" name="ids[]" value="5" />
<label for="id_5">#5 - ABC</label>
</li>
</ul>
</form>
</div>
</body>
</html>
[stylesheet.css]
body {
font-size: 12px;
background: #FFF;
color: #333;
margin: 0;
}
#container {
margin: 10px auto;
width: 600px;
padding: 10px;
}
[application,coffee]
$ ->
$('form').submit ->
false
$('input[name=filter]').live 'keyup', ->
query = $(this).val().toLowerCase()
if $(query).is(':blank')
$('form li').show()
else
$('form li').each (i, item) ->
text = $(item).find('label').text().toLowerCase()
if text.search(query) < 0
$(item).hide()
else
$(item).show()
몇 번 언급한 적이 있는 CoffeeScript를 사용했습니다.
[index.html]
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Checkbox Filter</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="stylesheet.css" media="screen" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js" type="text/javascript"></script>
<script src="application.coffee" type="text/coffeescript"></script>
</head>
<body>
<div id="container">
<form method="post" action="/">
<label for="input-filter">Filter:</label>
<input id="input-filter" type="text" name="filter" />
<ul>
<li>
<input id="id_1" type="checkbox" name="ids[]" value="1" />
<label for="id_1">#1 - AA</label>
</li>
<li>
<input id="id_2" type="checkbox" name="ids[]" value="2" />
<label for="id_2">#2 - BA</label>
</li>
<li>
<input id="id_3" type="checkbox" name="ids[]" value="3" />
<label for="id_3">#3 - AB</label>
</li>
<li>
<input id="id_4" type="checkbox" name="ids[]" value="4" />
<label for="id_4">#4 - BB</label>
</li>
<li>
<input id="id_5" type="checkbox" name="ids[]" value="5" />
<label for="id_5">#5 - ABC</label>
</li>
</ul>
</form>
</div>
</body>
</html>
[stylesheet.css]
body {
font-size: 12px;
background: #FFF;
color: #333;
margin: 0;
}
#container {
margin: 10px auto;
width: 600px;
padding: 10px;
}
[application,coffee]
$ ->
$('form').submit ->
false
$('input[name=filter]').live 'keyup', ->
query = $(this).val().toLowerCase()
if $(query).is(':blank')
$('form li').show()
else
$('form li').each (i, item) ->
text = $(item).find('label').text().toLowerCase()
if text.search(query) < 0
$(item).hide()
else
$(item).show()
댓글 2개
14년 전
[application,coffee] 여기서 , 는 . 이게 맞는거죠?
유용하게 쓰이겠네요 감사합니다.
유용하게 쓰이겠네요 감사합니다.
14년 전
헉, 마침표가 맞습니다!
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4230 |
|
14년 전 | 1556 | |
| 4229 | 14년 전 | 1116 | ||
| 4228 | 14년 전 | 2112 | ||
| 4227 | 14년 전 | 800 | ||
| 4226 |
|
14년 전 | 820 | |
| 4225 |
천국의눈믈
|
14년 전 | 637 | |
| 4224 |
visualp
|
14년 전 | 1437 | |
| 4223 |
visualp
|
14년 전 | 1050 | |
| 4222 |
visualp
|
14년 전 | 771 | |
| 4221 |
visualp
|
14년 전 | 5304 | |
| 4220 | 14년 전 | 1907 | ||
| 4219 | 14년 전 | 1151 | ||
| 4218 | 14년 전 | 644 | ||
| 4217 | 14년 전 | 9441 | ||
| 4216 | 14년 전 | 1557 | ||
| 4215 |
|
14년 전 | 575 | |
| 4214 | 14년 전 | 562 | ||
| 4213 | 14년 전 | 1433 | ||
| 4212 |
visualp
|
14년 전 | 2014 | |
| 4211 | 14년 전 | 1556 | ||
| 4210 | 14년 전 | 824 | ||
| 4209 |
|
14년 전 | 2053 | |
| 4208 | 14년 전 | 2054 | ||
| 4207 | 14년 전 | 3002 | ||
| 4206 | 14년 전 | 1100 | ||
| 4205 |
SGFlash
|
14년 전 | 1287 | |
| 4204 | 14년 전 | 815 | ||
| 4203 | 14년 전 | 896 | ||
| 4202 | 14년 전 | 2116 | ||
| 4201 | 14년 전 | 910 | ||
| 4200 | 14년 전 | 2379 | ||
| 4199 | 14년 전 | 631 | ||
| 4198 |
visualp
|
14년 전 | 3509 | |
| 4197 |
visualp
|
14년 전 | 731 | |
| 4196 | 14년 전 | 2091 | ||
| 4195 |
미사카10777호
|
14년 전 | 3470 | |
| 4194 |
senseme
|
14년 전 | 777 | |
| 4193 | 14년 전 | 954 | ||
| 4192 | 14년 전 | 1308 | ||
| 4191 |
DreamT
|
14년 전 | 802 | |
| 4190 |
onlymilk74
|
14년 전 | 1315 | |
| 4189 | 14년 전 | 1249 | ||
| 4188 | 14년 전 | 1373 | ||
| 4187 | 14년 전 | 1106 | ||
| 4186 |
|
14년 전 | 734 | |
| 4185 | 14년 전 | 1196 | ||
| 4184 | 14년 전 | 1172 | ||
| 4183 |
visualp
|
14년 전 | 1048 | |
| 4182 |
visualp
|
14년 전 | 627 | |
| 4181 |
|
14년 전 | 621 | |
| 4180 |
techer
|
14년 전 | 953 | |
| 4179 | 14년 전 | 526 | ||
| 4178 | 14년 전 | 3077 | ||
| 4177 | 14년 전 | 600 | ||
| 4176 | 14년 전 | 947 | ||
| 4175 | 14년 전 | 599 | ||
| 4174 |
|
14년 전 | 632 | |
| 4173 |
|
14년 전 | 1860 | |
| 4172 |
|
14년 전 | 907 | |
| 4171 | 14년 전 | 1393 | ||
| 4170 | 14년 전 | 665 | ||
| 4169 | 14년 전 | 1292 | ||
| 4168 | 14년 전 | 1774 | ||
| 4167 | 14년 전 | 816 | ||
| 4166 | 14년 전 | 1324 | ||
| 4165 |
visualp
|
14년 전 | 813 | |
| 4164 | 14년 전 | 1178 | ||
| 4163 | 14년 전 | 2605 | ||
| 4162 | 14년 전 | 660 | ||
| 4161 |
onlymilk74
|
14년 전 | 4795 | |
| 4160 | 14년 전 | 684 | ||
| 4159 | 14년 전 | 870 | ||
| 4158 | 14년 전 | 711 | ||
| 4157 | 14년 전 | 3391 | ||
| 4156 | 14년 전 | 505 | ||
| 4155 | 14년 전 | 840 | ||
| 4154 | 14년 전 | 1139 | ||
| 4153 | 14년 전 | 1142 | ||
| 4152 | 14년 전 | 635 | ||
| 4151 | 14년 전 | 1244 | ||
| 4150 | 14년 전 | 723 | ||
| 4149 | 14년 전 | 626 | ||
| 4148 |
쉽다zzz
|
14년 전 | 2259 | |
| 4147 | 14년 전 | 954 | ||
| 4146 | 14년 전 | 578 | ||
| 4145 | 14년 전 | 579 | ||
| 4144 | 14년 전 | 1617 | ||
| 4143 | 14년 전 | 771 | ||
| 4142 | 14년 전 | 1177 | ||
| 4141 | 14년 전 | 1165 | ||
| 4140 |
|
14년 전 | 1773 | |
| 4139 |
visualp
|
14년 전 | 1849 | |
| 4138 |
visualp
|
14년 전 | 1115 | |
| 4137 | 14년 전 | 769 | ||
| 4136 | 14년 전 | 710 | ||
| 4135 | 14년 전 | 960 | ||
| 4134 | 14년 전 | 1117 | ||
| 4133 | 14년 전 | 2531 | ||
| 4132 | 14년 전 | 577 | ||
| 4131 | 14년 전 | 895 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기