我是jQuery新手,我想使用复选框来启用和禁用下拉列表。这是我的html:
<select id="dropdown" style="width:200px">
<option value="feedback" name="aft_qst">After Quest</option>
<option value="feedback" name="aft_exm">After Exam</option>
</select>
<input type="checkbox" id="chkdwn2" value="feedback" />
要做到这一点,我需要哪些jQuery代码?还可以搜索好的jQuery文档/学习材料。
发布于 2011-10-09 19:52:11
这里有一种我希望很容易理解的方法:
$(document).ready(function() {
$("#chkdwn2").click(function() {
if ($(this).is(":checked")) {
$("#dropdown").prop("disabled", true);
} else {
$("#dropdown").prop("disabled", false);
}
});
});
发布于 2014-10-25 04:16:28
我使用的是JQuery > 1.8,这对我很有效……
$('#dropDownId').attr('disabled', true);
发布于 2011-10-09 19:54:13
试一下-
$('#chkdwn2').change(function(){
if($(this).is(':checked'))
$('#dropdown').removeAttr('disabled');
else
$('#dropdown').attr("disabled","disabled");
})
https://stackoverflow.com/questions/7703241
复制相似问题