嗨我有mouseenter和ajax触发器的问题。如果我专注于对象,如1秒钟,我想触发ajax。如果我离开了对象,它不应该触发ajax事件。
$('.popHover').mouseenter(function(e){
setTimeout(function(){
// ajax event here and pophover will show
},1000)
}).mouseout(function(e){
// close pophover
})
答案 0 :(得分:0)
您可以使用clearTimeout。
var timeout_id;
$('.popHover').mouseenter(function(e){
timeout_id = setTimeout(function(){
// ajax event here and pophover will show
},1000);
}).mouseout(function(e){
// close pophover
clearTimeout(timeout_id);
});