如果頁面加載和調整大小的窗口寬度小於768px,我不想觸發showCover()
函數。使用下面的代碼,即使窗口小於768px,它仍然被解僱。如果窗口寬度小於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()'結合事件處理程序,所以他們被束縛了一遍又一遍?這不好。 –