jQuery – :not() Selector

The jQuery not selector selects all elements that do not match the given selector. All selectors are accepted inside :not(), for example: :not(div a) and :not(div,a).

Source Code

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

<div class="div1">
	<input type="checkbox" checked="checked"/> checkbox 1
	<input type="checkbox" /> checkbox 2
<button>Click Here</button>

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


Following example finds all checkboxes that are not checked(inside div with class “div1”) and create a border.

checkbox 1
checkbox 2


No comments yet.

Leave a Reply