jquery插件 checkbox的全选、全部取消、反选

$.fn.check = function(mode){
var mode = mode || ‘on’;
return this.each(function(){
switch(mode){
case ‘on’:
this.checked = true;
break;
case ‘off’:
this.checked = false;
break;
case ‘toggle’:
this.checked = !this.checked;
break;
}
});
};

调用:
$(“input[@type=’checkbox’]”).check(‘on’)
$(“input[@type=’checkbox’]”).check(‘off’)
$(“input[@type=’checkbox’]”).check(‘toggle’)

发表评论

你必须 登录 才能发表评论.