Jquery 如何显示';兄弟姐妹';是否处于悬停状态,但不在正在悬停的项目上?

Jquery 如何显示';兄弟姐妹';是否处于悬停状态,但不在正在悬停的项目上?,jquery,css,Jquery,Css,我有5个文本位,我希望当你悬停在其中一个文本上时,css bellow将应用于除你悬停的文本位之外的所有文本位 您可以使用jquery和.sibles()属性来执行此操作吗 Html: 如果没有HTML,并且不知道应该将哪些规则应用于同级,则不能是特定的 $('a.blur').hover(function(){ $(this).siblings().addClass('someclass'); }, function(){ $(this).siblings().removeCl

我有5个文本位,我希望当你悬停在其中一个文本上时,css bellow将应用于除你悬停的文本位之外的所有文本位

您可以使用jquery和.sibles()属性来执行此操作吗

Html:


如果没有HTML,并且不知道应该将哪些规则应用于同级,则不能是特定的

$('a.blur').hover(function(){
    $(this).siblings().addClass('someclass');
}, function(){
    $(this).siblings().removeClass('someclass');
});

要做到这一点,您不能简单地使用
.sibbins()
,因为他们不是严格意义上的兄弟姐妹,更像是远房表亲:),所以为了加快速度,您应该在变量中保留所有项的列表,然后使用
.not(this)
排除
hover()
回调中的当前项

var items = $('.Home111 a'); // all anchors inside table with class Home111

items.hover(function() {
    var others = items.not(this);
    // others = the siblings of current item
}, function() {
    var others = items.not(this);
    // others = the siblings of current item
});

是的。sibles()可以,但是你能发布相关的HTML吗?
。sibles()
不是一个属性,而是一个函数;但是是的,它会选择一个项目的同级,不包括项目本身。现在,您只缺少JavaScript代码:)您好,谢谢您的帮助!如何“在某个地方保存一个变量中所有项目的列表”@maxmitch这在我的答案中真的:)@maxmitch你拿出来编辑一下,让我看看你做错了什么?不走运!是否有一种方法可以做到这一点,您可以更具体地将css应用于鼠标上方的特定“类”或“ID”?
$('a.blur').hover(function(){
    $(this).siblings().addClass('someclass');
}, function(){
    $(this).siblings().removeClass('someclass');
});
var items = $('.Home111 a'); // all anchors inside table with class Home111

items.hover(function() {
    var others = items.not(this);
    // others = the siblings of current item
}, function() {
    var others = items.not(this);
    // others = the siblings of current item
});