체크 박스 옵션이 많아져서 원하는 걸 찾기 어려울 때 사용하시면 됩니다.
몇 번 언급한 적이 있는 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년 전
헉, 마침표가 맞습니다!
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4630 | 13년 전 | 1189 | ||
| 4629 | 13년 전 | 4362 | ||
| 4628 | 13년 전 | 766 | ||
| 4627 |
|
13년 전 | 1760 | |
| 4626 | 13년 전 | 817 | ||
| 4625 |
마릴릴모니
|
13년 전 | 738 | |
| 4624 | 13년 전 | 1639 | ||
| 4623 |
SIR정회원
|
13년 전 | 620 | |
| 4622 |
rakoos
|
13년 전 | 1577 | |
| 4621 | 13년 전 | 687 | ||
| 4620 | 13년 전 | 1474 | ||
| 4619 | 13년 전 | 1002 | ||
| 4618 | 13년 전 | 4049 | ||
| 4617 | 13년 전 | 2044 | ||
| 4616 | 13년 전 | 862 | ||
| 4615 | 13년 전 | 686 | ||
| 4614 | 13년 전 | 1253 | ||
| 4613 | 13년 전 | 895 | ||
| 4612 |
rakoos
|
13년 전 | 1022 | |
| 4611 |
|
13년 전 | 2117 | |
| 4610 | 13년 전 | 772 | ||
| 4609 | 13년 전 | 2823 | ||
| 4608 | 13년 전 | 2813 | ||
| 4607 | 13년 전 | 1078 | ||
| 4606 | 13년 전 | 776 | ||
| 4605 | 13년 전 | 2317 | ||
| 4604 | 13년 전 | 892 | ||
| 4603 | 13년 전 | 1141 | ||
| 4602 |
한번잘해보자
|
13년 전 | 685 | |
| 4601 | 13년 전 | 1807 | ||
| 4600 |
|
13년 전 | 1090 | |
| 4599 |
크라운엠버서더
|
13년 전 | 1154 | |
| 4598 | 13년 전 | 1505 | ||
| 4597 | 13년 전 | 601 | ||
| 4596 | 13년 전 | 3693 | ||
| 4595 |
|
13년 전 | 921 | |
| 4594 | 13년 전 | 1799 | ||
| 4593 | 13년 전 | 1288 | ||
| 4592 | 13년 전 | 665 | ||
| 4591 | 13년 전 | 4650 | ||
| 4590 | 13년 전 | 525 | ||
| 4589 | 13년 전 | 2640 | ||
| 4588 |
|
13년 전 | 996 | |
| 4587 | 13년 전 | 659 | ||
| 4586 |
JavaDD
|
13년 전 | 1017 | |
| 4585 | 13년 전 | 7795 | ||
| 4584 | 13년 전 | 986 | ||
| 4583 |
PHPㅡASP프로그래머
|
13년 전 | 2066 | |
| 4582 |
PHPㅡASP프로그래머
|
13년 전 | 1503 | |
| 4581 |
PHPㅡASP프로그래머
|
13년 전 | 1025 | |
| 4580 | 13년 전 | 4098 | ||
| 4579 |
|
13년 전 | 693 | |
| 4578 | 13년 전 | 1192 | ||
| 4577 | 13년 전 | 823 | ||
| 4576 |
Kanzi
|
13년 전 | 882 | |
| 4575 |
|
13년 전 | 1562 | |
| 4574 | 13년 전 | 2354 | ||
| 4573 |
달빛소나타
|
13년 전 | 884 | |
| 4572 | 13년 전 | 1003 | ||
| 4571 | 13년 전 | 944 | ||
| 4570 |
|
13년 전 | 1317 | |
| 4569 |
한번잘해보자
|
13년 전 | 563 | |
| 4568 |
Raizond
|
13년 전 | 1034 | |
| 4567 |
Raizond
|
13년 전 | 539 | |
| 4566 |
Revenge
|
13년 전 | 955 | |
| 4565 |
|
13년 전 | 711 | |
| 4564 |
|
13년 전 | 1143 | |
| 4563 | 13년 전 | 1576 | ||
| 4562 | 13년 전 | 1226 | ||
| 4561 | 13년 전 | 9406 | ||
| 4560 | 13년 전 | 1811 | ||
| 4559 | 13년 전 | 3371 | ||
| 4558 | 13년 전 | 484 | ||
| 4557 | 13년 전 | 1456 | ||
| 4556 | 13년 전 | 718 | ||
| 4555 | 13년 전 | 556 | ||
| 4554 | 13년 전 | 550 | ||
| 4553 |
|
13년 전 | 4314 | |
| 4552 | 13년 전 | 1514 | ||
| 4551 | 13년 전 | 1994 | ||
| 4550 | 13년 전 | 685 | ||
| 4549 | 13년 전 | 1041 | ||
| 4548 | 13년 전 | 1579 | ||
| 4547 | 13년 전 | 565 | ||
| 4546 | 13년 전 | 1623 | ||
| 4545 | 13년 전 | 1338 | ||
| 4544 | 13년 전 | 3041 | ||
| 4543 | 13년 전 | 1018 | ||
| 4542 | 13년 전 | 2272 | ||
| 4541 | 13년 전 | 1141 | ||
| 4540 |
|
13년 전 | 1067 | |
| 4539 | 13년 전 | 1168 | ||
| 4538 | 13년 전 | 1595 | ||
| 4537 | 13년 전 | 1180 | ||
| 4536 | 13년 전 | 565 | ||
| 4535 |
|
13년 전 | 828 | |
| 4534 |
|
13년 전 | 982 | |
| 4533 | 13년 전 | 659 | ||
| 4532 |
soing
|
13년 전 | 7379 | |
| 4531 |
|
13년 전 | 6405 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기