.not()
.not( selector )
- 返回: domtify
从匹配元素集合中删除元素。
.not( selector ) from @1.0
.not( function ) from @1.0
- function
.not( selection ) from @1.0
- selection
- 类型: domtify
- 描述: 与当前元素集匹配的现有 domtify 对象。
从集合中排除掉一部分不需要的元素
例子:
html
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
</ul>
我们可以将此方法应用于列表项集:
js
d("li").not(":nth-child(2n)").css("background-color", "red")
此调用的结果是项目 1、3 和 5 的背景为红色,因为它们与选择器不匹配。