jQuery:具有类但不是$(this)的元素

Hel*_*mut 2 javascript jquery jquery-selectors

我有一个带图片的画廊和鼠标悬停在1张图片上我想用所有其他图片做(所以所有图片都有类.picture,除了一个悬停($(this)).

我尝试将类应用到类的所有图片,.picture然后在图片悬停时删除这个添加的类,然后使用添加的类(其中包含正确的图片),但它不能正常工作...

有没有更清洁,更好的方法来做到这一点?

例:

pic 1 -> do sth with this
pic 2 -> do sth with this
pic 3 -> gets hovered, don't do anything with this, exclude it from the selection!
Run Code Online (Sandbox Code Playgroud)

gra*_*ing 6

使用.not.

$('.picture').not(this);
Run Code Online (Sandbox Code Playgroud)