jQuery-如何反向选择?

jQuery-如何反向选择?,jquery,jquery-selectors,Jquery,Jquery Selectors,有没有办法做到这一点?:not()选择器似乎让我失望,因为它分别选择了每个元素的倒数,从而选择了所有7个div。不确定:not()的问题是什么,但这应该可以正常工作: $('.a-1').show().siblings([all those that do not belong to a-1]).hide(); 使用$('.a-1').show().sides(':not(.a-3')).hide()可以正常工作;a-1、a-2和a-1 a-2将被隐藏,因为您正在使用sibling()方法,否

有没有办法做到这一点?
:not()
选择器似乎让我失望,因为它分别选择了每个元素的倒数,从而选择了所有7个div。

不确定
:not()
的问题是什么,但这应该可以正常工作:

$('.a-1').show().siblings([all those that do not belong to a-1]).hide();
使用$('.a-1').show().sides(':not(.a-3')).hide()可以正常工作;a-1、a-2和a-1 a-2将被隐藏,因为您正在使用sibling()方法,否则使用$('.a-1')。而不是('.a-3').hide();只有a-1和a-1 a-2会隐藏。详情请浏览:
请考虑改进你的答案格式,纠正任何拼写错误。目前它很难阅读。可以找到有关堆栈溢出标记的指南
$('.a-1').show().siblings([all those that do not belong to a-1]).hide();
$('.a-1').show().siblings(':not(.a-1)').hide();