站长资源网络编程
jQuery 获取除某指定对象外的其他对象 ( :not() 与.not())
简介jquery获取除某指定对象外的其他对象.not() 遍历方法 从匹配元素集合中移除元素:not() 选择器 选取除了指定元素以外的所有元素。
- list item 1
- list item 2
-
jquery获取除某指定对象外的其他对象
.not() 遍历方法 从匹配元素集合中移除元素
:not() 选择器 选取除了指定元素以外的所有元素。
<ul> <li>list item 1</li> <li>list item 2</li> <li id="unwanted">list item 3</li> <li>list item 4</li> <li>list item 5</li> </ul>
获取ul中除
id="unwanted"的其他所有 li$('li:not(#unwanted)').css('background', 'red'); $('li').not('#unwanted').css('background', 'red');总结
以上所述是小编给大家介绍的jQuery 获取除某指定对象外的其他对象 ( :not() 与.not()),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!