mouseenter 上的 jQuery UI 滑动效果
我已经这样做了几天了,所以任何帮助将不胜感激。 我有一个链接,其中包含两个彼此叠置的 div。 顶部 div 被隐藏,但在 mouseenter
上滑入部分覆盖底部 div,然后在 mouseleave
上再次滑出。 它在一定程度上可以工作,但有一点问题。 这就是我对 jQuery 的了解(我从演示和文档中拼凑而成):
$(document).ready(function(){
$(".toggle").bind("mouseenter",function(){
$("> :eq(0)", this).show("slide", { direction: "down" });
}).bind("mouseleave",function(){
$("> :eq(0)", this).hide("slide", { direction: "down" });
});
});
这是页面结构(这是一个 WordPress 页面)
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" class="toggle">
<div id="slide" class="post-info" style="display: none;">
<h1><?php the_title(); ?></h1>
<ul>
<li>more info here</li>
<li>more info here</li>
</ul>
</div>
<div class="post-image">
<img src="<?php post_image('', false, false); ?>" width="275" height="155" />
</div>
</a>
</div>
I've been at this for a couple of days now, so any help would be much appreciated. I've got a link which contains two divs sitting on top of each other. The top div is hidden, but slides in to partially cover the bottom div on mouseenter
, and then out again on mouseleave
. It is working to a degree, but is a bit buggy. This is what I have for the jQuery (which I've pieced together from the demos and the documentation):
$(document).ready(function(){
$(".toggle").bind("mouseenter",function(){
$("> :eq(0)", this).show("slide", { direction: "down" });
}).bind("mouseleave",function(){
$("> :eq(0)", this).hide("slide", { direction: "down" });
});
});
and this is the page structure (it's a wordpress page)
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" class="toggle">
<div id="slide" class="post-info" style="display: none;">
<h1><?php the_title(); ?></h1>
<ul>
<li>more info here</li>
<li>more info here</li>
</ul>
</div>
<div class="post-image">
<img src="<?php post_image('', false, false); ?>" width="275" height="155" />
</div>
</a>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试这样的事情。
Try something like this.
谢谢伯克,但顶部 div 滑入部分覆盖底部 div,所以我不需要它滑出。 我会尝试你的语法,看看是否有任何改进。
——编辑——
发挥了魅力。 再次感谢。
Thanks Birk, but top div slides in to partially cover the bottom div, so I don't need it to slide out. I'll try your syntax though and see if there is any improvement.
-- edit --
Worked a charm. Thanks again.
您可能还想看看 jquery 的 Accordian 插件
You might also want to have a look at the accordian plugin for jquery