- $(function() {
- $.fn.manhuatoTop = function(options) {
- var defaults = {
- showHeight : 150,
- speed : 1000
- };
- var options = $.extend(defaults,options);
- $("body").prepend("<div id='totop'><a>返回</a></div>");
- var $toTop = $(this);
- var $top = $("#totop");
- var $ta = $("#totop a");
- $toTop.scroll(function(){
- var scrolltop=$(this).scrollTop();
- if(scrolltop>=options.showHeight){
- $top.show();
- }
- else{
- $top.hide();
- }
- });
- $ta.hover(function(){
- $(this).addClass("cur");
- },function(){
- $(this).removeClass("cur");
- });
- $top.click(function(){
- $("html,body").animate({scrollTop: 0}, options.speed);
- });
- }
- });
- //该片段来自于http://www.codesnippet.cn/detail/100720134537.html
来源: http://www.codesnippet.cn/detail/100720134537.html