jQuery – :enabled Selector

The jQuery enabled selector selects all elements that are enabled. 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 $(‘:enabled’) is equivalent to $(‘*:enabled’), so $(‘input:enabled’) 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("#div1 > input:enabled").wrap('<span></span>').parent().css({border:"3px #1E8CBE solid"});


Following example finds all input elements that are enabled (in a div having id=”div1″) and create a border around them.

checkbox 1
checkbox 2
checkbox 3
checkbox 4


No comments yet.

Leave a Reply