在 jquery 中启用/禁用下拉框 [英] Enable/Disable a dropdownbox in jquery
本文介绍了在 jquery 中启用/禁用下拉框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 jQuery 的新手,我想使用复选框启用和禁用下拉列表.这是我的 html:
I am new to jQuery and I want to enable and disable a dropdown list using a checkbox. This is my 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 文档/学习材料.
What jQuery code do I need to do this? Also searching for a good jQuery documentation/study material.
推荐答案
这里是一种我希望容易理解的方法:
Here is one way that I hope is easy to understand:
$(document).ready(function() {
$("#chkdwn2").click(function() {
if ($(this).is(":checked")) {
$("#dropdown").prop("disabled", true);
} else {
$("#dropdown").prop("disabled", false);
}
});
});
这篇关于在 jquery 中启用/禁用下拉框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文