jq checkbox 的全选并ajax传参的实例
实例如下:
/全选按钮 $("#all").click(function(){ if(this.checked){ $(":checkbox").prop("checked", true); }else{ $(":checkbox").removeAttr("checked"); } }); $("#form").on('click','.ids',function(){ var chknum = $("input[name='ids']:checkbox").size();//选项总个数 var chk = 0; $("input[name='ids']:checkbox:checked").each(function () { chk++; }); if(chknum==chk){//全选 $("#all").prop("checked",true); }else{//不全选 $("#all").removeAttr("checked"); } }); //上下架 $('#form').on('click','.up,.down',function(){ var my = $(this); var val = my.data('status'); var url = my.data('url'); var valArr = new Array; $("input[name='ids']:checkbox:checked").each(function(i){ valArr[i] = $(this).val(); }); var vals = valArr.join(','); $.ajax({ url: my.data('url'), method: 'post', data: { status: val, ids:vals }, success: function() { $("#all").removeAttr("checked"); table.search(); } }); });
相关推荐
zrtlin 2020-11-09
xuebingnan 2020-11-05
wikiwater 2020-10-27
heheeheh 2020-10-19
Crazyshark 2020-09-15
softwear 2020-08-21
ZGCdemo 2020-08-16
jczwilliam 2020-08-16
littleFatty 2020-08-16
idning 2020-08-03
jinxiutong 2020-07-26
lanzhusiyu 2020-07-19
Skyline 2020-07-04
xiaofanguan 2020-06-25
Aveiox 2020-06-23
dragonzht 2020-06-17