jQuery – :checkbox Selector

The jQuery checkbox selector selects all elements of type checkbox. jQuery(‘:checkbox’) is equivalent to jQuery(‘[type=checkbox]‘) or jQuery(‘input:checkbox’)

Source Code

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

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

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


Following example finds all checkbox inputs 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