联系我们
简单又实用的WordPress网站制作教学
当前位置:网站首页 > 网页前端技术 > 正文

jquery数组之存放checkbox全选值示例代码 - Web前端

作者:98wpeu发布时间:2026-08-07分类:网页前端技术浏览:6


导读:复制代码代码如下:<inputtype="checkbox"id="checkAll"value="1">全选/全部不选<inputtype="Chec...
复制代码 代码如下:
<inputtype="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>

标签:数组示例全选代码Webcheckbox


网页前端技术排行
最近发表
网站分类
标签列表