當前位置:首頁 » 購物大全 » jQuery購物車全選怎麼做

jQuery購物車全選怎麼做

發布時間: 2021-02-23 16:32:19

㈠ JS如何實現全選

簡單的如下,從後台讀取數據的時候為每家店鋪的商品單獨加類

<!DOCTYPEhtml>
<html>
<head>
<metacharset="UTF-8">
<scriptsrc="https://cdn.bootcss.com/jquery/2.0.0/jquery.js"></script>
<title></title>
</head>
<body>
<div><inputtype="checkbox"class="classA"/>店鋪:test1</div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"name="nameA"/></div>
<div><inputtype="checkbox"class="classB"/>店鋪:test2</div>
<div><inputtype="checkbox"name="nameB"/></div>
<div><inputtype="checkbox"name="nameB"/></div>
<div><inputtype="checkbox"name="nameB"/></div>
<div><inputtype="checkbox"name="nameB"/></div>
</body>
<script>
$(function(){
$(".classA").change(function(){
varstatus=$(".classA").prop("checked");
$("input[name='nameA']").attr("checked",status);
})
$(".classB").change(function(){
varstatus=$(".classB").prop("checked");
$("input[name='nameB']").attr("checked",status);
})
})
</script>
</html>

㈡ 怎麼用jquery通過點擊全選按鈕實現全選

HTML代碼:

<table>

<tr>

<td><input type="checkbox" name="b">全選</td><td>內容</td>

</tr>

<tr>

<td><input type="checkbox" name="a"></td><td>復選1</td>

</tr>

<tr>

<td><input type="checkbox" name="a"></td><td>復選2</td>

</tr>

<tr>

<td><input type="checkbox" name="a"></td><td>復選3</td>

</tr>

<tr>

<td><input type="checkbox" name="a"></td><td>復選4</td>

</tr>

<tr>

<td><input type="checkbox" name="a"></td><td>復選5</td>

</tr>

<tr>

<td><input type="checkbox" name="a"></td><td>復選6</td>

</table>

JAVASCRIPT代碼:

<script>

$("input[name='b']").click(function(){

//判斷當前點擊的復選框處於什麼狀態$(this).is(":checked") 返回的是布爾類型

if($(this).is(":checked")){

$("input[name='a']").prop("checked",true);

}else{

$("input[name='a']").prop("checked",false);

}

});

</script>

3

這樣就實現了全選和全不選。


㈢ jquery怎麼實現全選復選框

$('#checkedAll').click(function(){
if(this.checked){/*對默認抄是否為選中進行判斷*/
// $('[name=checkboxt]:checkbox').attr('checked',true);/*checked為true時為默認顯示的狀態,為true實現全選功能*/
// }else{
/ $('[name=checkboxt]:checkbox').attr('checked',false);/*false為反選即為全部選功能*/
// }
//實現全選全不選的另一種方法
$('[name=checkboxt]:checkbox').attr('checked',this.checked);/*checked為true時為默認顯示的狀態*/

});

//實現反選功能
$('#checkedRev').click(function(){

$('[name=checkboxt]:checkbox').each(function(){
this.checked=!this.checked;
});

㈣ 怎麼用jquery通過點擊全選按鈕實現全選 全不選

方法/步驟

HTML代碼:
<table>
<tr>
<td><input type="checkbox" name="b">全選</td><td>內容</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>復選1</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>復選2</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>復選3</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>復選4</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>復選5</td>
</tr>
<tr>
<td><input type="checkbox" name="a"></td><td>復選6</td>
</tr>
</table>
JAVASCRIPT代碼:
<script>
$("input[name='b']").click(function(){
//判斷當前點擊的復選框處於什麼狀態$(this).is(":checked") 返回的是布爾類型
if($(this).is(":checked")){
$("input[name='a']").prop("checked",true);
}else{
$("input[name='a']").prop("checked",false);
}
});
</script>
3
這樣就實現了全選和全不選

㈤ 用jquery怎麼實現全選/全不選

<script>
$("#seleall").click(function(){
$(":checkbox").attr("checked",true);
})
$("#selenone").click(function(){
$(":checkbox").attr("checked",false);
})
$("#selere").click(function(){
$(":checkbox").each(function(){
$(this).attr("checked",!$(this).attr("checked"))
});
})
</script>
需要三個復選框。按個按鈕
可實現全選專,全不選屬,反選

㈥ jQuery中做購物車的共有幾件商品怎麼做

那得看你查出來的數據是什麼樣的格式了,比如一種商品有兩件,這算是一條數據還是兩條數據,如果是一條數據,那麼直接統計數據條數就可以了,如果是兩條數據,就要去重計算商品數

㈦ 用jquery怎麼實現全選與反選

<ulid="list">
<li><label><inputtype="checkbox"value="1">1.時間都去哪兒了</label></li>
<li><label><inputtype="checkbox"value="2">2.海闊天空</label></li>
<li><label><inputtype="checkbox"value="3">3.真的愛你</label></li>
<li><label><inputtype="checkbox"value="4">4.不再猶豫</label></li>
<li><label><inputtype="checkbox"value="5">5.光輝歲月</label></li>
<li><label><inputtype="checkbox"value="6">6.喜歡你</label></li>
</ul>
<inputtype="checkbox"id="all">
<inputtype="button"value="全選"class="btn"id="selectAll">
<inputtype="button"value="全不選"class="btn"id="unSelect">
<inputtype="button"value="反選"class="btn"id="reverse">
<inputtype="button"value="獲得選中的所有值"class="btn"id="getValue">
$(function(){
//全選或全不選
$("#all").click(function(){
if(this.checked){
$("#list:checkbox").attr("checked",true);
}else{
$("#list:checkbox").attr("checked",false);
}
});
//全選
$("#selectAll").click(function(){
$("#list:checkbox,#all").attr("checked",true);
});
//全不選
$("#unSelect").click(function(){
$("#list:checkbox,#all").attr("checked",false);
});
//反選
$("#reverse").click(function(){
$("#list:checkbox").each(function(){
$(this).attr("checked",!$(this).attr("checked"));
});
allchk();
});

//設置全選復選框
$("#list:checkbox").click(function(){
allchk();
});

//獲取選中選項的值
$("#getValue").click(function(){
varvalArr=newArray;
$("#list:checkbox[checked]").each(function(i){
valArr[i]=$(this).val();
});
varvals=valArr.join(',');
alert(vals);
});
});
functionallchk(){
varchknum=$("#list:checkbox").size();//選項總個數
varchk=0;
$("#list:checkbox").each(function(){
if($(this).attr("checked")==true){
chk++;
}
});
if(chknum==chk){//全選
$("#all").attr("checked",true);
}else{//不全選
$("#all").attr("checked",false);
}
}

㈧ 如何用jQuery實現checkbox全選

全選:

$(":checkbox").attr("checked","checked");

全不選:

$(":checkbox").removeAttr("checked");

反選:

$(":checkbox:checked").removeAttr("checked");

$(":checkbox:not(:checked)").attr("checked","checked");

全手寫,沒有經過測試。

完整代碼如下,測試通過:

<html>
<head>
<title>如何用jQuery實現checkbox全選</title>
<scriptsrc="jquery-1.7.1.min.js"></script>
<scripttype="text/javascript">
//全選,全不選
functionallSelect(){
if($(":checkbox").attr("checked")!="checked"){
$(":checkbox").attr("checked","checked");
}
else{
$(":checkbox").removeAttr("checked");
}
}
//反選
functionotherSelect(){
$(":checkbox").each(function(){
if($(this).attr("checked")=="checked"){
$(this).removeAttr("checked");
}
else{
$(this).attr("checked","checked");
}
});
}
</script>
</head>
<body>
<inputid="Checkbox1"type="checkbox"/>
<inputid="Checkbox2"type="checkbox"/>
<inputid="Checkbox3"type="checkbox"/>
<inputid="Checkbox4"type="checkbox"/>
<inputid="Checkbox5"type="checkbox"/>
<inputid="Button1"type="button"value="全選"onclick="allSelect();"/>
<inputid="Button3"type="button"value="反選"onclick="otherSelect();"/>
</body>
</html>

㈨ jquery怎麼實現全選,全不選,刪除功能

全選全復不選

$("#cbxAll").click(function(){
if(this.checked){
$("input[name='你的制checkBox組的name']").prop("checked",true);
}
else{
$("input[name='你的checkBox組的name']").prop("checked",false);
}

});

至於刪除功能,這個是需要ajax去做了

㈩ 怎樣用jquery實現快速的全選全不選,超簡單

<labelfor="all">全選<inputid="all"type="checkbox"value=""/></label>
<labelfor="abc1">選擇內容1<inputid="abc1"name="abc"type="checkbox"value="1"/></label>
<labelfor="abc2">選擇2<inputid="abc2"name="abc"type="checkbox"value="2"/></label>
<labelfor="abc3">選擇3<inputid="abc3"name="abc"type="checkbox"value="3"/></label>
<labelfor="abc4">選擇4<inputid="abc4"name="abc"type="checkbox"value="4"/></label>
<script>
$(function(){
$("#all").click(function(){
$("input[name=abc]").prop("checked",$(this).prop("checked"));
});
});
</script>

熱點內容
斷背山有幾分鍾 發布:2024-08-19 08:31:17 瀏覽:253
日本電影 女老師和學生私奔 發布:2024-08-19 08:29:36 瀏覽:49
台灣電影 雙胞胎 發布:2024-08-19 08:02:18 瀏覽:134
2020最新電影在線觀看網站 發布:2024-08-19 07:56:06 瀏覽:641
男男電影虐 發布:2024-08-19 07:04:57 瀏覽:10
韓國電影李采潭主演的關於發廊的 發布:2024-08-19 07:01:57 瀏覽:2
每期都有做的動漫 發布:2024-08-19 06:44:33 瀏覽:778
東宮拍攝時間 發布:2024-08-19 06:44:12 瀏覽:5
林正英電影情節鬼抬轎 發布:2024-08-19 06:36:35 瀏覽:254
懂的都懂在線觀看網站 發布:2024-08-19 06:26:11 瀏覽:676