基于js實(shí)現(xiàn)checkbox批量選中操作
更新時間:2016年11月22日 14:01:38 作者:yangzailu1990
這篇文章主要為大家詳細(xì)介紹了基于js實(shí)現(xiàn)checkbox批量選中操作,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了js實(shí)現(xiàn)checkbox批量選中的具體代碼,供大家參考,具體內(nèi)容如下
<html >
<head>
<title>checkbox全選</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css"></style>
<script type="text/javascript"></script>
</head>
<body>
<table style="border:1px solid red;">
<tr>
<th style="background-color:#f7f7f7;width:8%;text-align:center;" class="lf">
<input name='chkAll' type='checkbox' id='chkAll' onClick="checkAll(this, 'id[]')" value='checkbox' /> 全選
</th>
<th style="background-color:#f7f7f7;width:8%;" class="lf">商品編號</th>
<th style="background-color:#f7f7f7;width:13%;" class="lf">名稱</th>
<th style="background-color:#f7f7f7;width:18%;" class="lf">標(biāo)題</th>
<th style="background-color:#f7f7f7;width:8%;" class="lf">品牌</th>
<th style="background-color:#f7f7f7;width:8%;" class="lf">組別</th>
</tr>
<tr>
<td class="lf" style="text-align:center;">
<input name='id[]' type='checkbox' value='{id}' onClick="checkItem(this, 'chkAll')">
</td>
<td class="lf">001</td>
<td class="lf">002</td>
<td class="lf">003</td>
<td class="lf">004</td>
<td class="lf">005</td>
</tr>
<tr>
<td class="lf" style="text-align:center;">
<input name='id[]' type='checkbox' value='{id}' onClick="checkItem(this, 'chkAll')">
</td>
<td class="lf">001</td>
<td class="lf">002</td>
<td class="lf">003</td>
<td class="lf">004</td>
<td class="lf">005</td>
</tr>
<tr height="45">
<td colspan="10" style="text-align:left;padding-left:40px;">
<input type="button" id="btn_show" value="批量展示" style="width:100px;margin-left:20px;">
</td>
</tr>
</table>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="checkbox.js"></script>
<script type="text/javascript">
/*var ids = [];
$('#btn_show').click(function(){
btnCheck('展示');
data = {
"ids":ids
};
$.ajax({
type:"POST",
url:"{:U('Mall/GoodsShow')}",
data:data,
//dataType:"json",
success:function(msg){
if(msg == 00){
alert("批量展示成功");
window.location.href='/index.php/Admin/Mall/MallList';
}else{
alert("批量展示失敗,請重新編輯");
}
},
error:function(){
alert("批量編輯失敗,請重新編輯");
}
});
});
function btnCheck(info){
var obj = $("input[name='id[]']:checked").each(function(){
ids.push($(this).val());
});
if (ids == false) {
alert("請選定要"+info+"的商品");
return false;
}else {
return ids;
}
}
*/
</script>
</body>
</html>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JS+CSS實(shí)現(xiàn)的藍(lán)色table選項(xiàng)卡效果
這篇文章主要介紹了JS+CSS實(shí)現(xiàn)的藍(lán)色table選項(xiàng)卡效果,通過鼠標(biāo)事件調(diào)用自定義函數(shù)實(shí)現(xiàn)頁面元素樣式的遍歷與動態(tài)切換效果,具有一定參考借鑒價值,需要的朋友可以參考下2015-10-10
如何用threejs實(shí)現(xiàn)實(shí)時多邊形折射
這篇文章主要介紹了如何用threejs實(shí)現(xiàn)實(shí)時多邊形折射,對three.js庫感興趣的同學(xué),可以參考下2021-05-05
webpack圖片轉(zhuǎn)為base64的實(shí)現(xiàn)示例
在開發(fā)過程中,圖片轉(zhuǎn)成base64是常有的事,本文主要介紹了webpack圖片轉(zhuǎn)為base64的實(shí)現(xiàn)示例,具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-12-12
npm install報(bào)錯無法創(chuàng)建packge.json文件的解決辦法
當(dāng)你在運(yùn)行 npm install 時遇到錯誤,提示無法找到 package.json 文件,也沒有創(chuàng)建一個 package.json 文件,只創(chuàng)建了一個package-lock.json文件,本文給大家介紹詳細(xì)的解決辦法,需要的朋友可以參考下2024-02-02
JavaScript動態(tài)設(shè)置div的樣式的方法
這篇文章主要介紹了JavaScript動態(tài)設(shè)置div的樣式的方法的相關(guān)資料,需要的朋友可以參考下2015-12-12

