.not()
描述: 从匹配的元素集合中移除指定的元素。
-
.not( selector )
-
selector类型: Selector一个用于匹配元素的选择器字符串。
-
-
.not( elements )
-
elements类型: Elements要从匹配元素集合中移除的一个或多个DOM元素。
-
-
.not( function(index) )
-
function(index)类型: Function()一个函数用作测试集合中的每个元素。
this
是当前DOM元素。
-
-
.not( jQuery object )
-
jQuery object类型: PlainObject现有匹配当前元素集合的jQuery对象。
-
.not()
方法构建一个新的匹配元素的jQuery对象,用于存放筛选后的元素。所提供的选择器是对每个元素进行测试;如果元素不匹配的选择将包括在结果中
例子:
Example: 为不是绿色或蓝色的 div 添加边框。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="jquery-1.10.2.js"></script>
<style>
div { width:50px; height:50px; margin:10px; float:left;
background:yellow; border:2px solid white; }
.green { background:#8f8; }
.gray { background:#ccc; }
#blueone { background:#99f; }
</style>
</head>
<body>
<div></div>
<div id="blueone"></div>
<div></div>
<div class="green"></div>
<div class="green"></div>
<div class="gray"></div>
<div></div>
<script>
$("div").not(".green,#blueone").css("border-color","red");
</script>
</body>
</html>
效果图:
Example: 从段落集合中移除 ID 是 "selected" 的元素。
1
|
|
Example: 从段落集合中移除 ID 是 "selected" 的元素。
1
|
|
Example: 从段落集合中移除满足 "div p.selected" 的元素。
1
|
|