0

我想在悬停时切换帖子列表中的隐藏元素。与 twitter 类似,当您将鼠标悬停在帖子上时,链接菜单将变得不隐藏。

每行帖子都有一个类“帖子”。这是我当前的代码:

$("div.post").mouseover(function() {
 $(this).css("background-color", "#f9f9f9");
});
$("div.post").mouseleave(function() {
 $(this).css("background-color", "white");
});

每行都有一个跨度类,称为“菜单”。

如何为悬停的帖子打开和关闭跨度“菜单”?

4

1 回答 1

1

对原始代码的简单链式修改:

$("div.post").mouseover(function() {
       $(this).css("background-color", "#f9f9f9").find('span.menu').stop(true,true).slideUp();
}).mouseleave(function() {
       $(this).css("background-color", "white").find('span.menu').stop(true,true).slideDown();
});

可以将幻灯片效果更改toggle()为两者,并且将隐藏/显示而没有效果。这stop()将防止跳跃,以便用鼠标快速进出

于 2012-10-28T23:08:41.360 回答