javascript - scoliIntoview jQuery 插件没有做任何事情
问题描述
我目前正在使用来自https://github.com/litera/jquery-scrollintoview的插件 scrollintoview并且无法正常工作,当我使用 jQuery.scrollintoview 进行测试时,该插件已准备就绪。
还测试了其他插件以进行滚动并且也无法正常工作。
这是我的js函数:
function scrollToId(id){
$('#'+id).scrollintoview({
duration: 1000,
direction: 'vertical',
complete: function () {
console.log('Ready');
}
});
}
这里是 index.html 中 js 文件的顺序
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollintoview/1.8/jquery.scrollintoview.min.js"></script>
<script src="js/index/index.js"></script>
使用此功能的一个示例是<button onclick="goToId('design')" ><h5>Design</h5></button>
,应该会上升到<div id="design"><h1>Design</h1></div>
并且控制台没有打印任何错误。
还使用来自https://github.com/flesler/jquery.scrollTo的插件 scrollTo 进行了测试,但它具有相同的行为。
解决方案
当您在 body 样式中使用 overflow-y:hidden 属性时,该插件不起作用:<body style="overflow-y:hidden;">
推荐阅读
- javascript - 提交按钮不改变问题
- python - 尝试通过 cmd 升级 pip 没有结果
- vue.js - 在 Vue 身份验证后获取用户名并使用户名反应
- excel - 如果范围是 Nothing 退出 sub、userform、specialcells
- serialization - Django rest 框架:有没有办法在使用序列化程序验证数据之前清理数据?
- logstash - Logstash 配置错误,我认为这是一个愚蠢的问题
- c++ - 有没有办法用忍者生成器在cmake中禁用“deps = gcc”的生成?
- jquery - 具有类对象和布尔数据类型的 Jquery ajax 调用
- javascript - 将猫鼬中的字符串日期与 Date.now() 或 new Date() 进行比较
- python - 使用同一类的方法为类导入模块