在jquery中启用/禁用dropdownbox [英] Enable/Disable a dropdownbox in jquery

查看:111
本文介绍了在jquery中启用/禁用dropdownbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jQuery的新手,我想使用复选框启用和禁用下拉列表。这是我的html:

 < select id =dropdownstyle =width:200px> 
< option value =feedbackname =aft_qst> After Quest< / option>
< option value =feedbackname =aft_exm> After Exam< / option>
< / select>
< input type =checkboxid =chkdwn2value =feedback/>

我需要什么jQuery代码?还要搜索一个好的jQuery文档/学习资料。

解决方案

这是一种我希望容易理解的方式: p>

http://jsfiddle.net/tft4t/

  $(document).ready(function(){
$(#chkdwn2)。click(function(){
($(this).is(:checked)){
$(#dropdown)。prop(disabled,true);
} else {
$ (#dropdown)。prop(disabled,false);
}
});
});


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" />

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:

http://jsfiddle.net/tft4t/

$(document).ready(function() {
 $("#chkdwn2").click(function() {
   if ($(this).is(":checked")) {
      $("#dropdown").prop("disabled", true);
   } else {
      $("#dropdown").prop("disabled", false);  
   }
 });
});

这篇关于在jquery中启用/禁用dropdownbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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