.not()
Syntax
.not(selector)
- selector: A string containing a selector expression to match elements against
.not(elements)
- elements: One or more DOM elements to remove from the matched set
.not(function)
- function: A function used as a test for each element in the set
Return value
The new jQuery object.
Description
Remove elements from the set of matched elements.
Examples
Not ID
<html>
<head>
<script src="http://java2s.com/Book/JavaScriptDemo/jQuery/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").not("#blue").css("border-color", "red");
});
</script>
<style>
p { width:60px; height:60px; margin:10px; float:left;
background:yellow; border:2px solid white; }
</style>
</head>
<body>
<body>
<p>asdf</p>
<p id="blue">asdf</p>
<p class="green">asdf</p>
<p class="gray">asdf</p>
</body>
</html>
Not class
<html>
<head>
<script src="http://java2s.com/Book/JavaScriptDemo/jQuery/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").not(".green").css("border-color", "red");
});
</script>
<style>
p { width:60px; height:60px; margin:10px; float:left;
background:yellow; border:2px solid white; }
</style>
</head>
<body>
<body>
<p>asdf</p>
<p id="blue">asdf</p>
<p class="green">asdf</p>
<p class="gray">asdf</p>
</body>
</html>
Home
JavaScript Book
jQuery
JavaScript Book
jQuery
DOM:
- jQuery DOM
- $("html tags"):generate code with the jQuery wrapper function.
- .add()
- .addClass()
- .after()
- .andSelf()
- .append()
- .appendTo()
- .attr()
- .before()
- .children()
- .clone()
- .closest()
- .contents()
- .css()
- .detach()
- .filter()
- .first()
- .get()
- .has()
- .hasClass()
- .height()
- .html()
- .index()
- .innerHeight()
- .innerWidth()
- .insertAfter()
- .insertBefore()
- .is()
- .last()
- .map()
- .next()
- .nextAll()
- .nextUntil()
- .not()
- .offset()
- .offsetParent()
- .outerHeight()
- .outerWidth()
- .parent()
- .parents()
- .parentsUntil()
- .position()
- .prepend()
- .prependTo()
- .prev()
- .prevAll()
- .prevUntil()
- .remove()
- .removeClass()
- .removeAttr()
- .replaceAll()
- .replaceWith()
- .siblings()
- .scrollLeft()
- .scrollTop()
- .slice()
- .text()
- .toArray()
- .toggleClass()
- .unwrap()
- .val()
- .wrap()
- .wrapAll()
- .wrapInner()
- .width()