标签:返回顶部 style blog color os io art re
// 悬浮置顶 ; (function ($) { $.fn.crumbsFixedPosition = function (options) { var defaults = { cName: ‘fixed_pos‘ } var options = $.extend(defaults, options); return this.each(function () { var $this = $(this); var t = $(this).offset().top; $(window).on(‘scroll‘, function () { if ($(this).scrollTop() > t) { $this.addClass(options.cName); } else { $this.removeClass(options.cName); } }); }); }; })(jQuery); $(function () { $(‘.curr_pos‘).crumbsFixedPosition(); });
// 返回顶部 ; (function ($) { $.fn.backToTop = function (options) { var defaults = { t: 200 } var options = $.extend(defaults, options); return this.each(function () { var $this = $(this); $this.append(‘<div class="backToTop"><span>返回顶部</span></div>‘); var $o = $this.find(‘.backToTop‘); $(window).on(‘scroll resize‘, function () { if ($(document).scrollTop() > 0) { $o.fadeIn(); } else { $o.fadeOut(); } }); $o.on({ ‘click‘: function () { $(‘body,html‘).stop(true, false).animate({ scrollTop: 0 }, options.t); }, ‘selectstart‘: function () { return false; } }); }); }; })(jQuery); $(function () { $(‘body‘).backToTop(); });
标签:返回顶部 style blog color os io art re
原文地址:http://www.cnblogs.com/rhythmK/p/3868457.html