我正在尝试使用 JS/JQuery 制作将淡出然后淡入不同数据(在本例中是图片)的图块,然后当您将鼠标移开时将其反转。现在我的代码在 Chrome 中运行良好,但是当我在 FireFox 中对其进行测试时,它会继续执行淡入/淡出命令。我查找了人们使用代码的类似情况,$(this).stop().fadeOut(function()
但由于我正在执行多个淡入淡出并加载信息,因此无法正确执行动画。有谁知道解决这个问题?
<script>
$(document).ready(function()
{
var hov = false;
$(".previewBox").mouseenter(function()
{
if(hov === false)
{
hov = true;
$(this).fadeOut(function()
{
$(this).load(function()
{
$(this).fadeIn();
});
$(this).attr("src", "Images/Portfolio/Art_Bike_Flip.png");
});
};
});
$(".previewBox").mouseleave(function()
{
if(hov === true)
{
hov = false;
$(this).fadeOut(function()
{
$(this).load(function()
{
$(this).fadeIn();
});
$(this).attr("src", "Images/Portfolio/Art_Bike_Preview.png");
});
};
});
});
</script>`enter code here`