我在我的网站上使用ascensor.js,我有一个jquery函数scrollTop的问题-它不工作。我尝试了不同的选项,但仍然没有任何反应。如何解决这个问题?
//编辑
抱歉的。下面是代码。
我正在使用这个简单的函数。
<a id="scrolltop"></a>
$(function () {
$('#scrolltop').click(function () {
$('html, body').animate({
scrollTop: '0px'
},
1500);
return false;
});
});现在,当我加入ascensor.js时,它就不再工作了。
发布于 2014-02-02 23:14:35
您尝试的是普通的jquery方式,您没有使用ascensor.js。这是两个版本,您可以看到其中的区别-
<head>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="jquery.ascensor.min.js" type="text/javascript"></script>
</head>下面是正文代码,对于临时的,我使用了固定的1000px来查看滚动效果。
<div style="height:1000px;">Some text with fixed height</div>
<a id="scrolltop" style="float:right;width:100%" href="#">jquery-version</a>
<div style="height:20px;"> </div>
<a id="ascensor" href="#">ascensor version</a>
<script type="text/javascript">
$(document).ready(function(){
// attach jquery version to id scrolltop
$('#scrolltop').click(function () {
$('html, body').animate({
scrollTop: '0px'
},
1500);
return false;
});
// attach ascensor to id ascensor
$('#ascensor').ascensor();
});
</script>当你点击jquery-version时,这并不是在使用as,而是因为你在使用动画,所以移动很慢。另一个版本是ascensor,默认情况下它会在顶部滚动。详细信息文档和implementation example可以为您提供在任何方向上移动动画的其他功能。
https://stackoverflow.com/questions/21502318
复制相似问题