jQuery操作布尔型的属性
全选,全不选,
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script src="./jquery-2.1.1.js"></script>
<body>
<h1>jQuery操作布尔型的属性</h1>
<h2>全选,全不选,</h2>
<input type="button" value="全选" οnclick="selectAll()" />
<input type="button" value="全不选" οnclick="unSelect()" />
<input type="button" value="反选" οnclick="reverse()" />
<p>选择1:<input type="checkbox" /></p>
<p>选择1:<input type="checkbox" /></p>
<p>选择1:<input type="checkbox" /></p>
<p>选择1:<input type="checkbox" /></p>
<p>选择1:<input type="checkbox" /></p>
</body>
<script>
function selectAll(){
//prop函数
$('input:checkbox').prop('checked',true);
}
function unSelect(){
$('input:checkbox').prop('checked',false);
}
function reverse(){
$('input:checkbox').each(function (){
this.checked = !this.checked;
})
}
</script>
</html>