:disabled JQ Home  <<  Selectors  <<  :disabled

UI element states pseudo-class match selector.

Shorthand version $(':disabled')

Description

The :disabled selector, selects all disabled elements.

If this selector is not preceded by another selector, the universal selector ("*") is implied and so the whole DOM will be searched. Use another selector as in the example below to narrow the search and improve performance.

Syntax

Signature Description
jQuery(':disabled')UI element states pseudo-class match

Parameters

None.

Return

N/A.

:disabled Example Selectors  <<  Top

Selects all disabled elements.

The following rather contrived example will check for disabled input elements and set a message in them with a yellow background when the button below is clicked.




$(function(){
  $('#btn20').on('click', function() {
    $("input:disabled").css('backgroundColor', 'yellow')
                       .val("this field disabled"); 
  });
}); 


Please fill in the form:


Your Information

 Enter your name:

Press the button below to action the above code:

Related Tutorials

jQuery Basic Tutorials - Lesson 3 - CSS Selectors