这段代码很好用,但是缺少我需要的东西。基本上,如果输入具有checked="checked"
属性,则应使其他两个元素保持禁用状态。如果未选中,则启用元素。
这是我在jsFiddle上的代码:http : //jsfiddle.net/arunpjohny/gMgm7/1/
这就是我的意见
<input class="test_priv1" type="checkbox" name="custom" id="custom" checked="checked" onclick="" />
我想这可以翻译为:如果我的输入得到检查,请禁用其他两个元素。如果我的输入中有“ checked =“ checked”,则使其他两个元素保持禁用状态。如果未选中我的输入,请启用两个元素。
得到它的工作:
$(document).ready(function() {
if ($('.test_priv1').is(':checked')){
$('.test_priv2, .test_priv3').prop('disabled',true);
}
$('.test_priv1').change(function () {
if(this.checked){
$('.test_priv2, .test_priv3').prop('disabled',true);
}else{
$('.test_priv2, .test_priv3').removeAttr('disabled');
}
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句