not

英 [nɒt]   美 [nɑ:t]  

adv.不;[用以表示否定、否认、拒绝、禁止等]不是;几乎不;未必,没有[用于否定后面的词或短语]

jquery not()方法 语法

作用:not() 从匹配元素集合中删除元素。

语法1:.not(selector)

参数:

参数描述
selector    字符串值,包含用于匹配元素的选择器表达式。

语法2:.not(element)

参数:

参数描述
element    一个或多个需要从匹配集中删除的 DOM 元素。  

语法3:.not(function(index))

参数:

参数描述
function(index) 用于检测集合中每个元素的函数。this 是当前 DOM 元素。

说明:如果给定一个表示 DOM 元素集合的 jQuery 对象,.not() 方法会用匹配元素的子集构造一个新的 jQuery 对象。所应用的选择器会检测每个元素;不匹配该选择器的元素会被包含在结果中。

jquery not()方法 示例

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js></script>
</head>
<body>
<p>This is a paragragh.</p>
<p>This is a paragragh.</p>
<p>This is a paragragh.</p>
<p id="selected">This is a paragragh.</p>
<p>This is a paragragh.</p>
<p>This is a paragragh.</p>
<script>
$("p").not("#selected").css('background-color', 'red');
</script>
</body>
</html>
运行实例 »

点击 "运行实例" 按钮查看在线实例

热门推荐

最新文章