input 选择 全选 反选

//选择与取消选择

$('input').prop('checked',true);

$('input').prop('checked',false);

//判断是否选中,在做反选的操作

if($(this).prev('.spaninput').children('input').is(":checked")){
  console.log('y');
  $(this).prev('.spaninput').children('input').prop('checked',false);
}else{
  console.log('n');
  $(this).prev('.spaninput').children('input').prop('checked',true);
};

//原生js

$(this).prev('.spaninput').children('input').get(0).checked=false;

$(this).prev('.spaninput').children('input').get(0).checked=true;

参考案例:

http://www.cnblogs.com/ghfjj/p/8079471.html

原文地址:https://www.cnblogs.com/ghfjj/p/8079446.html