我只想像在这个网站上一样创建动画http://www.msambition.de/ .我在其他上创建了 2 个 div 1。我有如下 jquery 代码: $(文档).ready(函数() {
$('div.unternehmen-ahover').hover(
function () {
$('div.unternehmen-ahover').slideToggle("slow");
$('span.span-picture-menu').fadeIn();
},
function () {
});
$('div.unternehmen').hover(
function () {
},
function () {
$('div.unternehmen-ahover').slideToggle("slow");
$('span.span-picture-menu').fadeOut();
});
});
问题是它在 hver 上工作正常,但它有时会保留在其他 div 上并且不进行滑动切换。请在这方面帮助我。
提前致谢
最佳答案
您应该为您的 div 创建 mouseenter 和 mouseleave 事件处理程序,并且您应该在那里创建 slideToggle。看这个link .
$(document).ready(function ()
{
$(".tile2").mouseenter(function () {
$(".trainingmood").delay(0).animate({ opacity: 0 }, 300, "");
$(".text2 span").delay(100).animate({ opacity: 1 }, 300, "");
$(".text2").animate({ marginLeft: "-=310px" }, 300);
});
$(".tile2").mouseleave(function () {
$(".trainingmood").delay(0).animate({ opacity: 1 }, 300, "");
$(".text2 span").animate({ opacity: 0 }, 3, 00, "");
$(".text2").animate({ marginLeft: "+=310px" }, 300);
})
});
关于javascript - 两个 div 相互动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19647723/