jQuery – :disabled Selector

The jQuery disabled selector selects all elements that are disabled. It is recommended to precede pseudo-class selectors (those that begin with a “:”) with a tag name or some other selector; otherwise, the universal selector (“*”) is implied. In other words, the bare $(‘:disabled’) is equivalent to $(‘*:disabled’), so $(‘input:disabled’) should be used instead.

Source Code

<!DOCTYPE html>
  <script src="http://code.jquery.com/jquery-latest.js"></script>

<div id="div1">
	<input type="checkbox" disabled="disabled"/> checkbox 1
	<input type="checkbox" /> checkbox 2
<div  id="div2">
	<input type="checkbox" /> checkbox 3
	<input type="checkbox" disabled="disabled"/> checkbox 4
<button>Click Here</button>

jQuery("button").click(function () {
	jQuery("input:disabled").wrap('<span></span>').parent().css({border:"3px #1E8CBE solid"});


Following example finds all input elements that are disabled and create a border around them.

checkbox 1
checkbox 2
checkbox 3
checkbox 4


No comments yet.

Leave a Reply