Disable/enable element with checkbox and jQuery?

前端 未结 6 1203
自闭症患者
自闭症患者 2020-12-29 11:11

I have a checkbox and if I tick it I want a textfield to become enabled (disabled as default) and when I untick the the checkbox I want it to become disabled again.

6条回答
  •  误落风尘
    2020-12-29 11:51

    show and hide a textbox(#otherSection2) for entering other options when last checkbox in a rendered table(#CheckBoxListList) of asp:CheckBoxList control is selected

     $("#CheckBoxListList input[type='checkbox']:last").on("click", function () {
    
                    if ($(this).is(":checked")) {
                        $("#otherSection2").show();
                    } else {
                        $("#otherSection2").hide().find("input").val(null);
    
                    }
                });
    

提交回复
热议问题