jquery实现购物车添加删除功能。 1. [代码] 无 script$(function(){$("table tr:nth-child(odd)").css("background-color",'#eee');$("#chkAll").click(function() {if(this.checked){$("table tr td input[type='checkbox']").prop("checked"
1. [代码]无
<script>
$(function(){
$("table tr:nth-child(odd)").css("background-color",'#eee');
$("#chkAll").click(function() {
if(this.checked){
$("table tr td input[type='checkbox']")
.prop("checked",true);
}else{
$("table tr td input[type='checkbox']")
.removeAttr("checked");
}
});
$("#btnDel").click(function(){
var intL=$("table tr td input:checked:not('#chkAll')").length;
console.log(intL);
if(intL){
$("table tr td input[type=checkbox]:not('#chkAll')").each(function(index){
if(this.checked){
$(this).parent().parent().remove();
}
})
}
})
});
</script>
