jQuery

[jQuery] jQuery Checkbox 선택

MorningPhys 2015. 7. 9. 17:23

jQuery로 Checkbox를 선택하는 방법입니다. *^^*

다른 좋은 방법도 있지만 간단히 필터로 선택해 보았습니다.

▣ checkbox.html

 

<!DOCTYPE html>

<html>

<head>

<style>

body {

font-size: 12px;

}

</style>

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

</head>

<body>

<form>

<input type="checkbox" name="test" checked/>1

<input type="checkbox" name="test" checked/>2

<input type="checkbox" />3

<input type="checkbox" name="test" checked/>4

<input type="checkbox" />5

<input type="hidden" />

</form>

<div id="count"></div>

<div id="check"></div>

<script>

var input = $("form input:checkbox");

$("#count").text("Checkbox Count = " + input.length);

$("#check").text("Checkbox Count [checked] = " + $('input:checkbox:checked').length);

</script>

</body>

</html>

 

 

▣ 페이지 로딩

 

반응형