체크 박스 옵션이 많아져서 원하는 걸 찾기 어려울 때 사용하시면 됩니다.
몇 번 언급한 적이 있는 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개
게시글 목록
| 번호 | 제목 |
|---|---|
| 12333 |
JavaScript
한글만 되게 하는 자바스크립트 입니다.
|
| 12332 |
JavaScript
간단한 팝업창 중앙에 띄우기 입니다.
|
| 12331 |
JavaScript
2단계 드롭다운 레이어 메뉴 입니다.
|
| 12329 |
JavaScript
동적 막대그래프
1
|
| 12328 |
JavaScript
간단한 위로가기 자바스크립트 입니다.
|
| 12327 |
JavaScript
따라다니는 link 퀵메뉴 입니다.
|
| 12326 |
JavaScript
글씨의 색을 자동으로 변환시켜주는 자바스크립트 입니다.
|
| 12325 |
JavaScript
인스타그램 사진가져오기
|
| 12324 |
jQuery
checkedbox 컨트롤
|
| 12323 |
jQuery
radio 컨트롤
|
| 12322 |
jQuery
select box 컨트롤
|
| 12321 | |
| 12320 |
node.js
Node.js - 실시간 위치 추적 (2)
|
| 12319 | |
| 12318 |
JavaScript
특정 이메일 입력 금지및 이메일 유효성 검사하기 입니다.
|
| 12317 |
JavaScript
마우스 오버시 그림 변하게 하는 자바스크립트 입니다
|
| 12316 |
JavaScript
시작과 멈춤이 가능한 스크롤 텍스트 입니다.
|
| 12315 |
JavaScript
이미지 없이 라운딩 박스 + 보더 표현하기 입니다.
|
| 12314 |
JavaScript
Trim 함수 자바스크립트로 사용하기 입니다.
|
| 12313 |
JavaScript
실제 이미지 크기 알아내기 입니다.
|
| 12312 |
JavaScript
present 자바스크립트 입니다.
|
| 12311 |
JavaScript
이미지 미리 로딩시켜놓기 입니다.
|
| 12310 |
JavaScript
다각형 이미지슬라이드쇼 자바스크립트 입니다.
|
| 12309 |
JavaScript
가운데 정렬된 홈페이지에서 따라다니는 레이어 자바스크립트 입니다.
|
| 12308 |
JavaScript
클릭시 펼쳐지는 메뉴 입니다.
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기