我想在用户即将离开页面时使用mouseleave触发 - 但是如果我在鼠标进入页面之前等待文档准备就绪,则鼠标离开会被触发! (谷歌浏览器)我做错了什么?
jQuery(document).ready(function($) {
$("body").bind("mouseleave",function(event) {
$("#signup").width($(window).width());
$("#signup").height($(window).height());
$("#signup").css({'display':'block','position':'absolute','top':'0','left':'0','opacity':'0.6'});
console.log('Window Width:'+$(window).width() +'Window Height:'+$(window).height());
});
});
答案 0 :(得分:0)
尝试使用此代码
$(document).bind("mouseleave",function(event) {
$("#signup").width($(window).width());
$("#signup").height($(window).height());
$("#signup").css({'display':'block','position':'absolute','top':'0','left':'0','opacity':'0.6'});
console.log('Window Width:'+$(window).width() +'Window Height:'+$(window).height());
});