i have a text box and a checkbox, when the checkbox is unchecked , i need to disabled the text box and when the user selects the checkbox, i want to re enable the textbox
i tried this:
asp.net code:/h3>
<div class="checkConfiguration">
<asp:CheckBox runat="server" ID="stopGeneralNumber" Text="General Number" CssClass="cbStopReason" Checked="false" />
<asp:TextBox runat="server" Enabled="false"></asp:TextBox>
</div>
Jquery code
$('.cbStopReason').on('click', function () {
if ($(this).attr('checked')) {
alert("now checked");
$(this).nextAll("input").removeAttr("disabled");
} else {
alert("now un checked");
$(this).nextAll("input").attr("disabled", "disabled");
}
})
the jquery code is already in document ready function, but the problem is that my code works good to disable the textbox, but it doesn't work to re enable it , what wrong did i do please?
Aucun commentaire:
Enregistrer un commentaire