我正在使用jQuery插件hoverIntent。問題有時在頁面加載時,鼠標已經在對象'#gallery'上,並且因此不會觸發hoverIntent代碼。jQuery hoverIntent不會觸發如果鼠標已經在文檔準備就緒的元素上
這裏是我的代碼示例:
$(document).ready(function(){
$('#gallery').hoverIntent(function(){
$('.gallery-thumbs').stop().animate({'height': '65px'},400); //in code animating a element child within #gallery
},function(){
$('.gallery-thumbs').stop().animate({'height': '33px'}); //out code animating a child element within #gallery
});
});
有誰知道一個解決方案嗎?
你真的需要使用該插件?它似乎只是在等待用戶的鼠標變慢之前進行調用。它基本上是一個超時的.hover事件。 另外,我認爲其他jQuery事件不會觸發,當jquery加載之前,鼠標在pageload上的元素。 –