zoukankan      html  css  js  c++  java
  • ↗☻【爆米花#SITE#】命名空间

    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
        <a href="">1</a>
        <a href="">2</a>
        <script>
            (function(window, document, undefined) {
                var MYAD = function(selector) {
                    return new MYAD.fn.init(selector);
                };
                MYAD.fn = MYAD.prototype = {
                    constructor: MYAD,
                    init: function(selector) {
                        this.selector = this[0] = selector;
                        return this;
                    }
                };
                MYAD.fn.init.prototype = MYAD.fn;
                MYAD.extend = MYAD.fn.extend = function() {
                    var target = arguments[0] || {},
                        i = 1,
                        length = arguments.length,
                        options,
                        name,
                        src,
                        copy;
                    if (length === i) {
                        target = this;
                        i--;
                    }
                    for (; i < length; i++) {
                        if ((options = arguments[i]) != null) {
                            for (name in options) {
                                src = target[name];
                                copy = options[name];
                                target[name] = copy;
                            }
                        }
                    }
                    return target;
                };
                MYAD.extend({
                    sayHi: function() {
                        console.log('hi');
                    },
                    sayHello: function() {
                        console.log('hello');
                    }
                });
                MYAD.fn.extend({
                    setColor: function() {
                        var sel = this[0];
                        var len = sel.length;
                        if (len > 1) {
                            while (len--) {
                                sel[len].style.background = '#f00';
                            }
                        } else {
                            sel.style.color = '#f00';
                        }
                    }
                });
                window.MYAD = MYAD;
            })(this, this.document);
            MYAD.sayHi();
            MYAD.sayHello();
            MYAD(document.getElementsByTagName('a')).setColor();
        </script>
    </body>
    </html>

    http://jquery.com/

  • 相关阅读:
    查杀木马利器,clamav
    zabbix运行久了以后效率会变慢的原因分析
    oracle sqlplus
    3000价位电脑配置实践
    phpmyadmin 万能密码漏洞
    nginx 的防cc攻击
    减少tcp TIME_WAIT 的数量
    nginx平滑升级
    心太大
    CentOS5.2下安装mplayer
  • 原文地址:https://www.cnblogs.com/jzm17173/p/2716342.html
Copyright © 2011-2022 走看看