我目前正在使用https://github.com/litera/jquery-scrollintoview的插件滚动视图,但没有工作,当我用jQuery.scrollintoview测试时,插件已经准备好了。
我还测试了其他插件的滚动功能,但也无法正常工作。
下面是我的js函数:
function scrollToId(id){
$('#'+id).scrollintoview({
duration: 1000,
direction: 'vertical',
complete: function () {
console.log('Ready');
}
});
}下面是js文件在index.html中的顺序
<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进行了测试,但它具有相同的行为。
https://stackoverflow.com/questions/50593467
复制相似问题