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

 

posted @ 2017-12-21 11:55  ghfjj  阅读(380)  评论(0编辑  收藏  举报