체크 박스 옵션이 많아져서 원하는 걸 찾기 어려울 때 사용하시면 됩니다.
몇 번 언급한 적이 있는 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년 전
헉, 마침표가 맞습니다!
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 4130 |
진정한승리v
|
14년 전 | 1067 | |
| 4129 | 14년 전 | 1429 | ||
| 4128 |
onlymilk74
|
14년 전 | 626 | |
| 4127 | 14년 전 | 540 | ||
| 4126 |
visualp
|
14년 전 | 1255 | |
| 4125 |
visualp
|
14년 전 | 1591 | |
| 4124 | 14년 전 | 1661 | ||
| 4123 | 14년 전 | 833 | ||
| 4122 |
visualp
|
14년 전 | 644 | |
| 4121 |
visualp
|
14년 전 | 1799 | |
| 4120 |
visualp
|
14년 전 | 868 | |
| 4119 |
visualp
|
14년 전 | 1240 | |
| 4118 |
그래픽노블
|
14년 전 | 694 | |
| 4117 |
visualp
|
14년 전 | 752 | |
| 4116 | 14년 전 | 741 | ||
| 4115 |
visualp
|
14년 전 | 826 | |
| 4114 |
onlymilk74
|
14년 전 | 4631 | |
| 4113 | 14년 전 | 742 | ||
| 4112 |
그래픽노블
|
14년 전 | 867 | |
| 4111 | 14년 전 | 1516 | ||
| 4110 | 14년 전 | 681 | ||
| 4109 | 14년 전 | 476 | ||
| 4108 | 14년 전 | 846 | ||
| 4107 | 14년 전 | 2116 | ||
| 4106 | 14년 전 | 1589 | ||
| 4105 |
onlymilk74
|
14년 전 | 1411 | |
| 4104 | 14년 전 | 2849 | ||
| 4103 | 14년 전 | 1956 | ||
| 4102 | 14년 전 | 929 | ||
| 4101 | 14년 전 | 988 | ||
| 4100 | 14년 전 | 945 | ||
| 4099 | 14년 전 | 1037 | ||
| 4098 |
Lonnie
|
14년 전 | 528 | |
| 4097 | 14년 전 | 829 | ||
| 4096 | 14년 전 | 977 | ||
| 4095 | 14년 전 | 2525 | ||
| 4094 | 14년 전 | 846 | ||
| 4093 | 14년 전 | 581 | ||
| 4092 |
|
14년 전 | 601 | |
| 4091 | 14년 전 | 2937 | ||
| 4090 | 14년 전 | 736 | ||
| 4089 |
|
14년 전 | 1447 | |
| 4088 | 14년 전 | 1447 | ||
| 4087 | 14년 전 | 645 | ||
| 4086 | 14년 전 | 1363 | ||
| 4085 | 14년 전 | 758 | ||
| 4084 | 14년 전 | 855 | ||
| 4083 | 14년 전 | 1817 | ||
| 4082 | 14년 전 | 1523 | ||
| 4081 | 14년 전 | 2126 | ||
| 4080 |
onlymilk74
|
14년 전 | 857 | |
| 4079 | 14년 전 | 754 | ||
| 4078 | 14년 전 | 2145 | ||
| 4077 |
DreamT
|
14년 전 | 774 | |
| 4076 | 14년 전 | 875 | ||
| 4075 | 14년 전 | 1982 | ||
| 4074 | 14년 전 | 1002 | ||
| 4073 | 14년 전 | 902 | ||
| 4072 |
onlymilk74
|
14년 전 | 659 | |
| 4071 | 14년 전 | 906 | ||
| 4070 | 14년 전 | 1919 | ||
| 4069 | 14년 전 | 484 | ||
| 4068 | 14년 전 | 2442 | ||
| 4067 | 14년 전 | 809 | ||
| 4066 | 14년 전 | 520 | ||
| 4065 | 14년 전 | 530 | ||
| 4064 | 14년 전 | 793 | ||
| 4063 | 14년 전 | 701 | ||
| 4062 | 14년 전 | 595 | ||
| 4061 | 14년 전 | 1093 | ||
| 4060 | 14년 전 | 523 | ||
| 4059 | 14년 전 | 1211 | ||
| 4058 | 14년 전 | 1580 | ||
| 4057 | 14년 전 | 536 | ||
| 4056 |
|
14년 전 | 669 | |
| 4055 |
SGFlash
|
14년 전 | 521 | |
| 4054 |
Priere
|
14년 전 | 665 | |
| 4053 | 14년 전 | 1090 | ||
| 4052 | 14년 전 | 789 | ||
| 4051 | 14년 전 | 917 | ||
| 4050 | 14년 전 | 739 | ||
| 4049 | 14년 전 | 881 | ||
| 4048 |
내꿈은대통령
|
14년 전 | 469 | |
| 4047 |
visualp
|
14년 전 | 1275 | |
| 4046 |
visualp
|
14년 전 | 616 | |
| 4045 |
visualp
|
14년 전 | 1380 | |
| 4044 | 14년 전 | 8136 | ||
| 4043 | 14년 전 | 764 | ||
| 4042 | 14년 전 | 1610 | ||
| 4041 | 14년 전 | 1328 | ||
| 4040 | 14년 전 | 1601 | ||
| 4039 | 14년 전 | 1943 | ||
| 4038 | 14년 전 | 536 | ||
| 4037 |
sider
|
14년 전 | 679 | |
| 4036 | 14년 전 | 6470 | ||
| 4035 | 14년 전 | 655 | ||
| 4034 | 14년 전 | 592 | ||
| 4033 |
techer
|
14년 전 | 1741 | |
| 4032 | 14년 전 | 646 | ||
| 4031 | 14년 전 | 640 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기