Javascript jQuery:包含类但不包含$的元素(this)
我有一个图库,里面有图片,鼠标放在一张图片上。我想用所有其他图片做点什么(所以所有图片都有类Javascript jQuery:包含类但不包含$的元素(this),javascript,jquery,jquery-selectors,Javascript,Jquery,Jquery Selectors,我有一个图库,里面有图片,鼠标放在一张图片上。我想用所有其他图片做点什么(所以所有图片都有类。图片,除了一张悬停($(this)) 我试图用class.picture将一个类应用于所有图片,然后在图片悬停时删除此添加的类,然后使用添加的类(其中包含正确的图片),但它无法顺利工作 有没有更干净更好的方法 例如: pic 1 -> do sth with this pic 2 -> do sth with this pic 3 -> gets hovered, don't do a
。图片,除了一张悬停($(this)
)
我试图用class.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!
使用。而不是
$('.picture').not(this);
var img = $('.picture');
img.on('hover', function() {
img.not(this).each(function() {
/* do Something with $(this); */
})
});