如何用jQuery编写购物车商品增删功能?
- 内容介绍
- 文章标签
- 相关推荐
本文共计108个文字,预计阅读时间需要1分钟。
使用jQuery实现购物车添加删除功能。1. [代码] 无 script$(function(){$(table tr:odd).css(background-color,);});
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>
本文共计108个文字,预计阅读时间需要1分钟。
使用jQuery实现购物车添加删除功能。1. [代码] 无 script$(function(){$(table tr:odd).css(background-color,);});
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>

