我试图在淡入淡出的元素上设置超时时间,所以它在淡入/淡出之前有一点点的缓冲。出于某种原因,我的setTimeout函数似乎不工作。我以前遇到过这个麻烦,我真的很想知道为什么。setTimeout不起作用?
这是我使用什么目前:
var button_timer;
if (fade_in_but_hover != "none" && fade_out_but_hover != "none") {
$(".first-level-items > .li").hover(function() {
clearTimeout(button_timer);
$(this).find("a").first().animate({ color: font_color_hover }, fade_in_but_hover);
}).mouseleave(function() {
button_timer = setTimeout(function() {
$(this).find("a").first().animate({ color: font_color }, fade_out_but_hover);
}, 1000);
});
}
。李可能是一个错字! –