使用 jquery 查找文本框是否被禁用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8963781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 11:20:31  来源:igfitidea点击:

Find if a textbox is disabled or not using jquery

jqueryhtml

提问by Vaibhav Jain

I need to find if a textbox is disabled or enabled using Jquery.

我需要使用 Jquery 查找是否禁用或启用了文本框。

回答by Joseph Silber

.prop('disabled')will return a Boolean:

.prop('disabled')将返回一个布尔值:

var isDisabled = $('textbox').prop('disabled');

Here's the fiddle: http://jsfiddle.net/unhjM/

这是小提琴:http: //jsfiddle.net/unhjM/

回答by ShankarSangoli

You can find if the textbox is disabled using ismethod by passing :disabledselector to it. Try this.

您可以is通过将:disabled选择器传递给它来使用方法来确定文本框是否被禁用。尝试这个。

if($('textbox').is(':disabled')){
     //textbox is disabled
}

回答by sshow

You can use $(":disabled")to select all disabled items in the current context.

您可以使用$(":disabled")选择当前上下文中的所有禁用项。

To determine whether a single item is disabled you can use $("#textbox1").is(":disabled").

要确定单个项目是否被禁用,您可以使用$("#textbox1").is(":disabled").

回答by Ismael Fdez

You can check if a element is disabled or not with this:

您可以使用以下命令检查元素是否被禁用:

if($("#slcCausaRechazo").prop('disabled') == false)
{
//your code to realice 
}

回答by Rajat Bansal

 if($("element_selector").attr('disabled') || $("element_selector").prop('disabled'))
 {

    // code when element is disabled

  }