87,923
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题</title>
</head>
<script type="text/javascript" src = "js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
$('#b1').click(function(){
$("input[type='checkbox']").each(function(){
$(this).attr("checked",true);
});
});
$('#b3').click(function(){
$("input[name='ck']").each(function(){
$(this).attr("checked",false);
});
});
$('#b2').click(function(){
$("input[name='ck']").each(function(){
this.checked=!this.checked;
});
});
});
</script>
<body>
<input type = "checkbox" name = "ck" value = "0">北京
<input type = "checkbox" name = "ck" value = "1">上海
<input type = "checkbox" name = "ck" value = "2">武汉
<input type = "checkbox" name = "ck" value = "3">黄石
<br>
<input type = "button" name = "b1" id = "b1" value ="全选" >
<input type = "button" name = "b2" id = "b2" value ="反选" >
<input type = "button" name = "b3" id = "b3" value ="清空" >
</body>
</html>
this.checked=!this.checked;
[/quote]
jquery 还繁琐。。那easy ui 名字就取错了。。[/quote]
你自己仔细对比下就知道了this.checked=!this.checked;
[/quote]
jquery 还繁琐。。那easy ui 名字就取错了。。 已经解决了,是checkbox有个一个位置拼错了
<script type="text/javascript"> $(function() { $('#b1').click(function(){ $("input[name='ck']").prop("checked",true); }); $('#b2').click(function(){ $("input[name='ck']").each(function(){ $(this).prop("checked", !$(this).prop("checked")); }); }); $('#b3').click(function(){ $("input[name='ck']").prop("checked",false); }); }); </script>
this.checked=!this.checked;
已经解决了,是checkbox有个一个位置拼错了
<script type="text/javascript">
$(function() {
$('#b1').click(function(){
$("input[name='ck']").prop("checked",true);
});
$('#b2').click(function(){
$("input[name='ck']").each(function(){
$(this).prop("checked", !$(this).prop("checked"));
});
});
$('#b3').click(function(){
$("input[name='ck']").prop("checked",false);
});
});
</script>