我有一个有几百个元素的页面,这需要一个鼠标悬停的QTip。这正在扼杀IE8,尽管其他浏览器看起来运行得很好。
为了解决这个问题,我尝试在用户将鼠标悬停在元素的容器上时创建QTips,这样它一次只执行~100-200次操作,而不是一次执行所有的1,000+。
$('#color-family /*ID of body*/> .strctr-contain /*containing class*/').live('mouseover', function(){
$(this).children('.palette .color-swatch, .stain-swatch, .color-swatch-dash').qtip({//foo}
})
});当您将鼠标悬停在容器上时,此函数确实会触发,但是,当您将鼠标悬停在孩子上时,它只会一次又一次地触发此函数,而不是显示工具提示。
发布于 2012-01-13 01:24:08
也许使用"one“函数是最好的,它会为你做所有的事情。
$('#color-family /ID of body/> .strctr-contain /containing class/').one('mouseover', function(){
$(this).children('.palette .color-swatch, .stain-swatch, .color-swatch-dash').qti({//foo} );
});发布于 2012-01-13 01:18:44
这将在鼠标悬停绑定运行一次时将其删除...
$('#color-family /*ID of body*/> .strctr-contain /*containing class*/').on("mouseover", function(){
$(this).children('.palette .color-swatch, .stain-swatch, .color-swatch-dash').qtip({ //foo }).off("mouseover");
});它只需要添加unbind (关闭)即可。
发布于 2012-01-13 01:20:48
好吧,如果我们可以只使用绑定函数,我会尝试在第一次创建qtips后取消绑定操作:
$(‘# /ID -body的颜色族/>.strctr-包含鼠标类/’).bind(‘鼠标悬停’,/containing (){
$(this).children('.palette ..color swatch,.color-swatch,.color-swatch-dash').qtip({//foo} );$(this).unbind('mouseover');
});
https://stackoverflow.com/questions/8838974
复制相似问题