当前位置: 移动技术网 > IT编程>开发语言>Jquery > css中:not()选择器和jQuery中.not()方法

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

2018年10月23日  | 移动技术网IT编程  | 我要评论

因为老是将这两个的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(...);


如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网