多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
~~~ --------------------html部分--------------------------------- <form name="testForm" id="myForm"> <input type="checkbox" name="ids" value="1" />1<br /> <input type="checkbox" name="ids" value="2" />2<br /> <input type="checkbox" name="ids" value="3" />3<br /> <input type="checkbox" name="ids" value="4" />4<br /> <input type="checkbox" name="ids" value="5" />5<br /> <input type="checkbox" name="ids" value="6" />6<br /> <input type="checkbox" name="ids" value="7" />7<br /> <input type="checkbox" name="ids" value="8" />8<br /> <button type="button" οnclick="fun()">js</button> <button type="button" οnclick="jqueryFun()">jquery</button> </form> --------------------js部分------------------------------ <script> //原生获取 function fun(){ obj = document.getElementsByName("ids");//input框name check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } //用JQ的ajax提交 $.ajax({ url: "{:url('blog/datadel')}", data:{check_val}, type: 'post', success: function (data) { if (data.code == 1) { layer.alert(data.msg, {icon: 6}, function (index) { layer.close(index); window.location.href = "{:url('index')}";//跳转 }); } else { layer.alert(data.msg, {icon: 5}, function (index) { layer.close(index); }) } } }) } //JQ获取 function jqueryFun(){ var ids = []; $("input[name='ids']:checked").each(function(i){//ids是input框name ids.push($(this).val()); }); //用JQ的ajax提交 $.ajax({ url: "{:url('blog/datadel')}", data:{ids}, type: 'post', success: function (data) { if (data.code == 1) { layer.alert(data.msg, {icon: 6}, function (index) { layer.close(index); window.location.href = "{:url('index')}";//跳转 }); } else { layer.alert(data.msg, {icon: 5}, function (index) { layer.close(index); }) } } }) } </script> ~~~