无法处理禁用复选框 [英] Unable to handle disable check box
本文介绍了无法处理禁用复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的html:
< div class =check>
< input class =sfCheckboxtype =checkboxtitle =viewdisabled =truechecked =checked>
< input class =sfCheckboxtype =checkboxtitle =viewchecked =checked>
< / div>
在jquery中我试试:
<$ p $ ($ .c $ c> $('.check.sfCheckbox')。attr('checked',false);
代码正常,但我想要('checked',false)
如果复选框不是禁用。如何获得期望的结果。谢谢。
我的意思是如果复选框被禁用,则不执行任何操作。 ',假。谢谢。
解决方案
试试这个:
添加一个 .not('[disabled]')
在你的语句中会做的伎俩
$( '.check .sfCheckbox')。not('[disabled]')。attr('checked',false);
此语句将取消选中所有'enabled'
与类检查
的元素中的类
sfCheckbox
复选框my html:
<div class="check">
<input class="sfCheckbox" type="checkbox" title="view" disabled="true" checked="checked">
<input class="sfCheckbox" type="checkbox" title="view" checked="checked">
</div>
in jquery i try:
$('.check .sfCheckbox').attr('checked', false);
code work fine but i want to ('checked', false)
if check box is not disable.How to get desire result.Thanks.
i mean if check box is disable do nothing .if not 'checked', false.Thanks.
解决方案
Try this:
Adding a .not('[disabled]')
in your statement will do the trick
$('.check .sfCheckbox').not('[disabled]').attr('checked', false);
This statement will uncheck all 'enabled'
check boxes with class sfCheckbox
that are inside an element with class check
这篇关于无法处理禁用复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文