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")
精彩评论