Find if a textbox is disabled or not using jquery

后端 未结 5 1562
情书的邮戳
情书的邮戳 2020-12-23 14:06

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

相关标签:
5条回答
  • 2020-12-23 14:41

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

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

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

    0 讨论(0)
  • 2020-12-23 14:42

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

    if($('textbox').is(':disabled')){
         //textbox is disabled
    }
    
    0 讨论(0)
  • 2020-12-23 14:43

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

    if($("#slcCausaRechazo").prop('disabled') == false)
    {
    //your code to realice 
    }
    
    0 讨论(0)
  • 2020-12-23 14:45

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

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

    0 讨论(0)
  • 2020-12-23 14:55
     if($("element_selector").attr('disabled') || $("element_selector").prop('disabled'))
     {
    
        // code when element is disabled
    
      }
    
    0 讨论(0)
提交回复
热议问题