【发布时间】:2017-05-09 22:02:41
【问题描述】:
我知道这可能是一个非常基本的问题,但我在 fullPage.js 脚本 (https://github.com/alvarotrigo/fullPage.js) 的帮助下构建了一个网站,但对 jQuery/Javascript 了解甚少。
我想要做的是禁用窗口宽度为 800 像素及以下的脚本,但将其启用为更高。或者,我想在脚本中以相同的条件将某个变量设置为 false。
这就是脚本的样子(我删除了一些设置以使其更短):
<script>
$(document).ready(function() {
$('#fullpage').fullpage({
responsiveWidth: 800,
continuousVertical: true
});
});
</script>
这是我试图让它简单地工作,但它似乎不起作用:
<script type="text/javascript">
if ( $(window).width() > 800) {
$(document).ready(function() {
$('#fullpage').fullpage({
responsiveWidth: 800,
continuousVertical: true
});
});
}
</script>
【问题讨论】:
-
您可能希望在
$(document).ready函数中使用if ($(window).width()..。甚至可能在$(window).resize(function () { });事件处理程序中。 -
你链接到 jquery 库了吗?
标签: javascript jquery html fullpage.js responsiveness