全选,反选 form提交数据

2017-10-31  本文已影响0人  过往_eed8

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);

})

})

上一篇 下一篇

猜你喜欢

热点阅读