• js 获取高度,宽度,绑定事件


    获取滚动条高度:

    document.documentElement.scrollTop

    绑定事件:

    var addEvent = (function () {
                if (document.addEventListener) {
                    return function (el, type, fn) {
                        if (el.length) {
                            for (var i = 0; i < el.length; i++) {
                                addEvent(el[i], type, fn);
                            }
                        } else {
                            el.addEventListener(type, fn, false);
                        }
                    };
                } else {
                    return function (el, type, fn) {
                        if (el.length) {
                            for (var i = 0; i < el.length; i++) {
                                addEvent(el[i], type, fn);
                            }
                        } else {
                            el.attachEvent('on' + type, function () {
                                return fn.call(el, window.event);
                            });
                        }
                    };
                }
            })();


            addEvent(window, 'scroll', fixedFun);

  • 相关阅读:
    不冒任何险,什么都不做,什么也不会有,什么也不是
    jquery的$().each,$.each的区别
    SpringMVC的几种返回方式
    MySQL创建数据库并赋予权限
    Java微信公众号开发
    Mybatis批量删除
    JavaMail邮件开发
    JSON 数组的遍历解析
    按小时统计的语句
    Linux下安装Redis3.2.4
  • 原文地址:https://www.cnblogs.com/lzf0514/p/2649408.html
Copyright © 2020-2023  润新知