HLJ 发布于
2019-04-15 17:00:54

css中:not()选择器和jQuery中.not()方法

因为老是将这两个的not方法弄混,所以写一下备忘。

css中:not()选择器用法

:not 伪类选择器可以筛选不符合表达式的元素,:not(selector) 其中的selector为css选择器
ul li:not(:first-child)
ul li:not(.text) //不包含class="text"的元素
:not(p) //非段落元素
ul li:not(:first-child):not(:last-child)  //not可叠加使用

jQuery中.not()方法

not() 从匹配元素集合中删除元素。
$("p").not("#selected")  //选择id!=selected的段落元素
$('li').not(':even').css('background-color', 'red');  //选择不是偶数的li元素
选择class!=test的input元素的两种方法
$(input:not(.test)).css(...);
$(input).not(".test").css(...);
文章来源:文章转载https://www.cnblogs.com/yyjbk/archive/2018/10/23/9830484.html
最后生成于 2023-06-18 18:32:56
此内容有帮助 ?
0