Is there any prope开发者_开发问答rty in jquery to help me check if a txtbox is disabled? and it lets me compare through an if statement?
for example:
if ($('#ctl00_ContentPlaceHolder1_TextBox3'). == "false")
{
}
The :disabled selector was designed to do just that:
if ($("#ctl00_ContentPlaceHolder1_TextBox3").is(":disabled")) {
// Text box is disabled.
}
If you're using jQuery 1.6 or higher, it's also safe to access the boolean DOM property with prop():
if ($("#ctl00_ContentPlaceHolder1_TextBox3").prop("disabled")) {
// Text box is disabled.
}
You can use :disabled selector.
Try:
if ($('#ctl00_ContentPlaceHolder1_TextBox3').is(":disabled"))
{
}
or
if ($('#ctl00_ContentPlaceHolder1_TextBox3:disabled').length)
{
}
You can use the :enabled
pseudoselector.
http://api.jquery.com/enabled-selector/
if($('#MyInput').attr('disabled') == 'disabled'){
//Do something
}
$("#ctl00_ContentPlaceHolder1_TextBox3").is(":enabled")
will return the value of enabled status.
You can use .prop()
if you are using jQuery 1.6+.
if ($('#ctl00_ContentPlaceHolder1_TextBox3').prop('disabled')) { ... }
精彩评论