有沒有什麼辦法來檢測鼠標指針多少秒保持一個HTML元素?jQuery的檢測鼠標多少秒停留在元素
我想找回鼠標多少秒停留在元素放少許延遲一個回調事件......如果可能:)
我與一個簡單的()循環檢測嘗試通過計數器:
var time_over ;
$('.bean-active').live('mouseover',function(){
id_tag = $(this).attr("id");
for(time_over = 1;time_over <= 3000;time_over ++){
if(time_over == 3000){
$('.bean-bubble,.bean-bubble img').hide();
$('#bean-bubble-'+id_tag+',#bean-bubble-'+id_tag+' img').show();
}
}
});
的問題是,它不工作:(
也是我想結合mouseLeave事件,腳本邏輯應該是:
while (mouseover element count how many time it stays over)
if (time == n)
{ do somenthing }
if (mouseleave from element earlier then time)
{ do somenthing different }
嘗試將鼠標懸停意向(google一下) – mtahmed
使用,現在:),但似乎超時不爲我的作品:P。 – sbaaaang
$( '豆處於激活狀態 '),住(' 鼠標懸停',函數() {(this).hoverIntent({){function(){ id_tag = $(this).attr(「id」); $(this).fadeTo(100,0.5).fadeTo(200,1 ); $( '豆氣泡,.bean氣泡IMG ')隱藏(); $(' #豆氣泡 - '+ id_tag +',#豆氣泡 - '+ id_tag +' IMG')。顯示(); }, 超時:900, 出:函數(){ 返回假; } }); $(this).trigger('mouseover'); }); – sbaaaang