Ant*_*ore 9 jquery class this selector next
我想我正在寻找与$(这个)相反的东西.
如果我有3个具有相同类的元素,我如何只选择我没有单击的元素.例如:
<div class="test"></div>
<div class="test"></div>
<div class="test"></div>
Run Code Online (Sandbox Code Playgroud)
然后我点击中间div,我如何只对第一个和最后一个元素实现效果?
Nic*_*tti 15
你可以使用not():
$('div.test').click(function(){
var notClicked = $('.test').not(this);
});
Run Code Online (Sandbox Code Playgroud)