jQuery – :checked Selector

The jQuery checked selector matches all elements that are checked. The :checked selector works for checkboxes and radio buttons. For select elements, use the :selected selector.

Source Code

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

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

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


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

checkbox 1
checkbox 2
checkbox 3
checkbox 4


No comments yet.

Leave a Reply