我有以下脚本
<script>
$(document).ready(function(){
$("div.mover").hover(function () {
$("div.hide1").fadeTo("slow", 0.33);
$("div.hide1").fadeTo("slow", 1);
},function(){
$("div.hide1").stop();
});
});
</script>
and html page is
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div class="mover"><IMG SRC="images/buttons_full_01.png" ></div></td>
</tr>
<tr>
<td><div class="mover"><IMG SRC="images/buttons_full_02.png"></div></td>
</tr>
<tr>
<td><div class="mover"><IMG SRC="images/buttons_full_03.png"></div></td>
</tr>
</table>我的功能是在鼠标经过按钮时淡出背景
但问题是,如果我将鼠标悬停在所有按钮上,并在鼠标左键后继续动画,直到它完成所有事务。
我想要的是:当鼠标左键时,按钮动画转到$(“div.hide1”).fadeTo(“div.hide1”,1);然后停止
发布于 2009-10-21 23:52:36
只要不将鼠标指针拖到第二个(或第三个) "mover“div上,您的初始函数就可以正常工作。当发生这种情况时,您可能会得到几个动画,如下所示:
mover1.hover-over()
mover2.hover-over()默认情况下,调用stop仅终止当前动画-为第一个移动器启动的动画,而不是为第二个移动器排队的动画。
您可以通过在调用接受可选参数clearQueue的stop时清除动画队列来阻止运行其他动画
$(document).ready(function(){
$("div.mover").hover(function () {
$("div.hide1").fadeTo("slow", 0.33).fadeTo("slow", 1);
}, function(){
// Added stop parameters and added an additional fadeTo,
// to make sure we get back to 100% opacity.
$("div.hide1").stop(true).fadeTo("slow", 1);
});
});https://stackoverflow.com/questions/1601427
复制相似问题