天天看点

复选框的全选全不选的功能

html

<input type="button" id="allcz" value="批量操作" />

循环出来的复选框

<input type="checkbox" name="creative_id[]" value="{$vo.creative_id}">//注意一定要加[],这样提交过去是一个creative_id数组,进行批量操作

js

$("#allcz").click(function(){  

       $("input[name='creative_id[]']").each(function(){  

           if (this.checked) {

                this.checked = false;

            }

            else {

                this.checked = true;

            }

       });

  });