【发布时间】:2014-01-23 08:42:33
【问题描述】:
如果页面加载和调整大小时的窗口宽度小于 768 像素,我不想触发 showCover() 函数。使用下面的代码,即使窗口小于 768px,它仍然会被触发。
function ipsThemeViewer() {
jQuery(window).resize(function() {
if ( jQuery(window).width() < 768 ) return false;
showCover();
}).resize();
}
function showCover() {
jQuery('#ipsThemeViewerScreen').hover(function () {
var t = jQuery(this);
jQuery('.cover').stop().fadeIn('fast');
}, function () {
var t = jQuery(this);
jQuery('.cover').stop().fadeOut('fast');
});
}
【问题讨论】:
-
你明白
.hover()绑定事件处理程序,所以它们被一遍又一遍地绑定吗?这很糟糕。
标签: javascript jquery jquery-hover window-resize