开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜