[英]JQuery .fadeIn() levels off when hiding and reshowing an element
So I'm designing a website (using WordPress), and I want to use JQuery to hide/show a certain element when another element is moused over. 因此,我正在设计一个网站(使用WordPress),并且当鼠标悬停在另一个元素上时,我想使用JQuery隐藏/显示某个元素。 The HTML looks roughly like this HTML大致如下所示
<div class="post" style="clear:both;">
<a href="...">
<img src="..." />
</a>
<div class="autohide">
<h3>
<a href="...">...</a>
</h3>
<p>....</p>
</div>
</div>
...
<div class="spacer" />
and the JQuery looks like this: JQuery看起来像这样:
jQuery(document).ready(function(){
jQuery(".post .autohide").hide();`
jQuery(".post").hover(function() {
jQuery(this).nextAll(".spacer").first().stop().html(jQuery(this).children(".autohide")
.html()).fadeIn();
},function() {
jQuery(this).nextAll(".spacer").stop().show().fadeOut().html("").hide();
});
});
What's supposed to happen is, when the user mouses over the image, the contents of the associated autohide <div>
get transplanted into the next spacer <div>
and then faded in; 应该发生的是,当用户将鼠标悬停在图像上时,关联的自动隐藏<div>
的内容将被移植到下一个间隔<div>
,然后逐渐淡入; when they mouse out, the autohide <div>
fades out and clears. 当它们移出鼠标时,自动隐藏<div>
淡出并清除。
However, if the pointer is not over the image for the full fade-in time, then the max opacity of the spacer div seems to decrease until a mouse-over creates no effect at all. 但是,如果指针在整个淡入时间内没有位于图像上方,则间隔div的最大不透明度似乎会降低,直到将鼠标悬停完全没有效果为止。
I would be much obliged if anyone who knows more JQuery than I could shed some light on this subject; 如果有人比我更了解JQuery,那么我将非常有责任。 I assume it's a basic problem (I've never used JQuery before this project). 我认为这是一个基本问题(在此项目之前,我从未使用过JQuery)。
Thanks in advance. 提前致谢。
I took the .stop()
calls out, and it seems to work fine, but I am still trying to parse everything that is going on. 我退出了.stop()
调用,它似乎工作正常,但我仍在尝试解析所有正在发生的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.