我是靠谱客的博主 懵懂外套,这篇文章主要介绍jQuery 获取除某指定对象外的其他对象 ( :not() 与.not()),现在分享给大家,希望可以做个参考。

 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()),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对靠谱客网站的支持!

最后

以上就是懵懂外套最近收集整理的关于jQuery 获取除某指定对象外的其他对象 ( :not() 与.not())的全部内容,更多相关jQuery内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(116)

评论列表共有 0 条评论

立即
投稿
返回
顶部