jQuery复选框 [英] jQuery Checkboxes

查看:114
本文介绍了jQuery复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图写一个jQuery代码,如果所有的复选框都是未选中,那么所有li标签都有类禁用但是,如果选中了一个复选框(任何复选框),则所有[li]标签都会失去禁用类别。



b

解决方案

  $(':checkbox' ).toggleClass('disabled',!$(':checkbox:checked')。length); 
});


I'm trying to write a piece of jQuery code where, if all checkboxes are "unchecked", then all li tags have the class "disabled."

But, if one checkbox (any checkbox) is checked, then all [li] tags lose the class "disabled".

Many thanks!

解决方案

$(':checkbox').click(function () {
    $('li').toggleClass('disabled', !$(':checkbox:checked').length);
});

这篇关于jQuery复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆