zoukankan      html  css  js  c++  java
  • jquery返回顶部和底部插件和解决ie6下fixed插件

    (function($){
        //返回顶部和底部插件
        $.fn.extend({ 
            goTopBootom:function (options){
                //默认参数
                var defaults = {
                    "upBtn":".up", //被点击返回顶部的按钮
                    "downBtn":".down", //被点击返回底部的按钮
                    "inTms":300, //此功能元素出现的时间
                    "outTms":300, //此功能元素隐藏的时间
                    "speed":500 //返回顶部或者底部的速度
                };
                var options = $.extend(defaults,options)
                return this.each(function(){
                    var _this = $(this);
                    var oHtmlBody = $('html,body');
                    var oBodyH = document.body.clientHeight;
                    var oUp = $(this).find(options.upBtn);
                    var oDown = $(this).find(options.downBtn);
                    $(this).css("top",window.screen.availHeight/2-100+"px");
                    $(window).scroll(function() {        
                        if($(window).scrollTop() >= 200){
                            _this.fadeIn(options.inTms); 
                        }else{    
                            _this.fadeOut(options.inTms);    
                        }  
                    });
                    oUp.click(function(){oHtmlBody.animate({scrollTop: '0px'}, options.speed);});
                    oDown.click(function(){oHtmlBody.animate({scrollTop: oBodyH + 'px'}, options.speed);});
                });
            },
            //解决ie6下fixed插件
            ie6fixedbug: function () {
                return this.each(function(){
                    var m = (window.screen.height - $(this).height()) / 3;
                    var obj = $(this);
                    $(window).scroll(function () {
                        obj.css("top",(document.body.scrollTop || document.documentElement.scrollTop) + m + 'px');
                    });
                    $(window).resize(function () {
                        obj.css("top",(document.body.scrollTop || document.documentElement.scrollTop) + m + 'px');
                    });
                });
            }
        });
    }(jQuery));
  • 相关阅读:
    WHAT I WANT TO DO ?
    BACK找工作感悟
    C++基础六-结构体
    C++基础五-指针
    C++基础四-函数
    C++基础三-数组

    C++基础三-循环控制
    C++基础二-条件判断
    PHP 基础
  • 原文地址:https://www.cnblogs.com/afuge/p/3291992.html
Copyright © 2011-2022 走看看