【发布时间】:2015-08-07 18:25:34
【问题描述】:
我需要让这个脚本在宽度为 794 像素或更高的屏幕上运行。 对于较小的屏幕尺寸,它不应该运行,因为这会导致另一个脚本出现问题。
我尝试了不同的东西,但我真的不知道如何做到这一点。
jQuery(document).ready(function ($) {
$('a[href*=#]:not([href=#])').click(function () {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
谁能告诉我,我如何调整它以让这个脚本在屏幕宽度 794 像素或更高的屏幕上运行?
最好的问候 萨法克
【问题讨论】:
标签: javascript jquery scroll width screen