美文网首页
全选,反选 form提交数据

全选,反选 form提交数据

作者: 过往_eed8 | 来源:发表于2017-10-31 09:04 被阅读0次

jQuery(function($){

//全选

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

$("input[name='checkbox[]']").attr("checked","true");

})

//取消全选

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

$("input[name='checkbox[]']").removeAttr("checked");

})

//选中所有基数

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

$("input[name='checkbox']:even").attr("checked","true");

})

//选中所有偶数

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

$("input[name='checkbox']:odd").attr("checked","true");

})

//反选

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

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

if($(this).attr("checked"))

{

$(this).removeAttr("checked");

}

else

{

$(this).attr("checked","true");

}

})

})

//或许选择项的值

var aa="";

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

$("input[name='checkbox']:checkbox:checked").each(function(){

aa+=$(this).val()

})

document.write(aa);

})

})

相关文章

网友评论

      本文标题:全选,反选 form提交数据

      本文链接:https://www.haomeiwen.com/subject/cfvvpxtx.html