代码如下:
<input type="checkbox" id="checkall" value="1">全选/全部不选
<input type="checkbox" name="items" value="1">1
<input type="checkbox" name="items" value="2">2
<input type="checkbox" name="items" value="3">3
<input type="checkbox" name="items" value="4">4
<input type="checkbox" name="items" value="5">
<input type="button" onclick="show()" value="提示选择的">
<script>
$("#chekcall").click(function(){
if(this.checked){
$("input[name=items]").attr("checked","checked");
}
else{
$("input[name=items]").attr("checked",null);
}
})
function show(){
var strids=new array();//声明一个存放id的数组
$("input[name=items]").each(function (i,d){
if (d.checked) {
strids.push(d.value);
}
})
if(strids.length<1)
alert("您没有选中项!");
else{
var ids=strids.join(",");
alert("你选中的字符串有:"+ids);
}
}
</script>
如对本文有疑问, 点击进行留言回复!!
【JavaScript笔记(一)】万丈高楼平地起 - 基本概念篇
轻松解决 org.apache.taglibs.standard.tlv.JstlCoreTLV 困惑
vert实践五——Json?Protocol Buffer?FlatBuffers?
[基于tensorflow的人脸检测] 基于神经网络的人脸检测8——验证训练好的神经网络
网友评论