先引入js:
<script type="text/javascript" src="jquery.js" ></script><script type="text/javascript" src="towhere.js" ></script>
假设页面:
使用方法:
$(function(){ $('#to-bottom').click(function(){ $.toBottom(); }); $('#to-top').click(function(){ $.toTop(); }); $('#to-where1').click(function(){ $.toWhere(500); }); $('#to-where2').click(function(){ $.toWhere(1000); }); /* $.toBottom(); 去向底部,$.toBottom(0.1)--[0.1-可选参数-运动速度],默认0.3 $.toTop(); 返回顶部,调整同上 $.toWhere(); 到任何处,$.toWhere(500,0.1)--[500-必填到达何处,0.1--可选速度],默认0.3 */ });
插件下载: