jQuery - 在 div 上悬停时,在 div 中滑动并能够将鼠标悬停在新打开的 div 上
我试图将鼠标悬停在底部栏上,该底部栏将在其上方的另一个 div 中滑动,我可以单击位于其中的项目,然后当我将鼠标移开时,“出现的 div”将滑开。
但是,当我从底部栏移动鼠标以单击新出现的 div(在 div 中滑动)中的某些内容时,它会重新启用该效果,我如何才能停止此操作,以便我可以将鼠标悬停在两者上(在 div 中滑动之后)启用)并了解如何重新启动效果,本质上是将其放入相同的 SlideDown/slideUp 效果的循环中。
这是我的代码:
$(".playlist").hide();
$(".player, .playlist").hover(
function(){ $(".playlist").slideDown(); },
function(){ $(".playlist").slideUp(); }
);
和我的 HTML:
<div class="playlist">
<!-- This would display some content that I can click on -->
</div>
<div class="player">
<!-- This expands across the whole window and is fixed to the bottom -->
</div>
I'm trying to do hover over bottom bar, which will slide in another div just above it which I can click items located within on and then when i mouse off both the "appeared div" will slide away.
However, when I move my mouse from the bottom bar to click on something in the newly appeared div (slid in div) it re-enabled the effect, how can I stop this so I can hover over both (after the slid in div is enabled) and have it how restart the effect essentially placing it into a loop of the same slideDown/slideUp effect.
Here's my code:
$(".playlist").hide();
$(".player, .playlist").hover(
function(){ $(".playlist").slideDown(); },
function(){ $(".playlist").slideUp(); }
);
And my HTML:
<div class="playlist">
<!-- This would display some content that I can click on -->
</div>
<div class="player">
<!-- This expands across the whole window and is fixed to the bottom -->
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://jsfiddle.net/jv25Y/
新标记
新 JS
这样的东西有用吗?现在基本上播放列表包含在播放器中。因此,当您尝试单击播放列表中的链接时,您的鼠标不会离开播放器。如果这不太适合(由于页面上的样式等),您也可以将一个元素包裹在播放列表和播放器周围,然后在其上调用悬停,如下所示,
Markup
JS
http://jsfiddle.net/jv25Y/
New Markup
New JS
Would something like that work? Basically playlist is contained in player now. So your mouse will not leave player, when you are trying to click a link in playlist. If that doesnt quite fit (due to styling on your page etc) You can also just wrap an element around playlist and player and then call hover on it instead like this,
Markup
JS