The problem is that I am unable to set disabled
attribute to disabled using jQuery. I am able to set checked
property but not disabled
property. Any help will be appreciated! Thank you in advance!
HTML:
<div class="special-review">
<label></label>
<asp:CheckBox ID="chkspecialreview" TabIndex="26" runat="server" ClientIDMode="Static" CssClass="chkspecialreview" Text="Exam requires special review" />
</div>
Javascript:
$("#chkspecialreview").attr('checked', 'checked'); // This is working
$("#chkspecialreview").attr('disabled', 'disabled'); // This is not working
$("#chkspecialreview").attr('disabled', true); // This is not working
$("#chkspecialreview").prop('disabled', true); // This is not working
Using jQuery v2.1.1 seems to be working. You should check if the content is in DOM
before applying the change. Using .attr("disabled", true);
works as expected (as seen in the snippet below).
$("#check").attr("checked", true); $("#check").attr("disabled", true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="checkbox" id="check"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.