欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery數(shù)組之存放checkbox全選值示例代碼

 更新時(shí)間:2013年12月20日 17:28:25   作者:  
使用jquery數(shù)組可以存放checkbox全選值,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下
復(fù)制代碼 代碼如下:

<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();//聲明一個(gè)存放id的數(shù)組
$("input[name=items]").each(function (i,d){
if (d.checked) {
strIds.push(d.value);
}
})
if(strIds.length<1)
alert("您沒(méi)有選中項(xiàng)!");
else{
var ids=strIds.join(",");
alert("你選中的字符串有:"+ids);
}


}

</script>

相關(guān)文章

最新評(píng)論