以下代码导致内存泄漏(您可以看到这种情况发生的时间越多,您进出的速度就越慢).不幸的是我无法在我的办公室下载一个javascript探查器(我可以,它只需要几天/几周).
这是代码,只是下拉菜单的一些简单转换:
$(document).ready(function(){
breadcrumbOver = function () {
$(this).stop().animate({ backgroundColor: "#3393b5", textIndent: 15 }, 250);
}
breadcrumbOut = function () {
$(this).stop().animate({ backgroundColor: "#738793", textIndent: 0 }, 250);
}
$("nav ul li").hover(
function () {
$(this).children('ul.child').stop().slideDown('fast').children('li').hover(breadcrumbOver, breadcrumbOut);
},
function () {
$(this).children('ul.child').stop().slideUp('fast').unbind(breadcrumbOver, breadcrumbOut);
}
);
});
Run Code Online (Sandbox Code Playgroud)
任何人都可以看到可能发生内存泄漏的地方?
编辑:活生生的例子在这里- http://rcnhca.org.uk/sandbox/(在"健康,安全和保安"反复滚再滚了它的孩子看到效果发生,也动画了slideDown并不有时如果火你进出的速度足够快.