开发者

Jquery to enable/disable a drop down list on checking/unchecking a check box in Ruby

开发者 https://www.devze.com 2023-04-06 21:52 出处:网络
I am new to ruby and jQuery as well. I have a drop down list which should be enabled/disabled on checking/unchecking a check box.It would be of great he开发者_如何转开发lp if someone could help with

I am new to ruby and jQuery as well.

I have a drop down list which should be enabled/disabled on checking/unchecking a check box.It would be of great he开发者_如何转开发lp if someone could help with the jQuery for this.

thanks, Ramya.


Try this:

$(document).ready(function(){
    $("#yourCheckBoxId").change(function(){
        if($(this).attr("disabled").length)
        {
            $("#yourDropDownId").removeAttr("disabled");
        }
        else
        {
            $("#yourDropDownId").attr("disabled", "disabled");
        }
    });
});

(untested)


Recent versions of jquery support .prop method.

example: $("#dropdownid").prop("disabled", "true")

0

精彩评论

暂无评论...
验证码 换一张
取 消