jQuery类级别插件--返回顶部,底部,去到任何部位

先引入js:
<script type="text/javascript" src="jquery.js" ></script>
<script type="text/javascript" src="towhere.js" ></script>

假设页面:

    <body>
        <a href="javascript:;" id="to-bottom">去到底部</a>
        <a href="javascript:;" id="to-top">返回顶部</a>
        <div id="to-where1">去到500处</div>
        <div id="to-where2">去到1000处</div>
    </body>

使用方法:

    $(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
         
         */
    });

插件下载:

http://pan.baidu.com/share/link?shareid=2575574326&uk=3945321701

原文地址:https://www.cnblogs.com/barrior/p/4166513.html