zoukankan      html  css  js  c++  java
  • Javascript

     function on(node,type,funchandler) {
                node = typeof node == "string" ? document.getElementById(node) : node;
                if (!document.all) {
                    node.addEventListener(type, funchandler);
                } else {
                    node.attachEvent("on"+type,funchandler);
                }
            }
    
            function trim(ostr) {
                return ostr.replace(/^s+|s+$/g, '');
            }
    
            function isNumber(s) {
                return !isNaN(s);
            }
    
            function isString(s) {
                return typeof s == "string";
            }
    
            function isBoolean(s) {
                return typeof s == 'boolean';
            }
    
            function isNull(s) {
                return s == null;
            }
    
            function isUndefined(s) {
                return typeof s == "undefined";
            }
    
            function isEmpty(s) {
                return /^s*$/.test(s)
            }
    
            function isArray(s) {
                return s instanceof Array;
            }
    

      

     /*
            claaName:类名
            root:根元素
            tag:标签类型
            */
            function getElementsByClassName(claaName, root, tag) {
                var arr = [];
                if (root) {
                    root = typeof root == 'string' ? document.getElementById(root) : root;
                } else {
                    root = document.body;
                }
                tag = tag || '*';
                var eles = root.getElementsByTagName(tag);
                for (var i = 0; i < eles.length ; i++) {
                    for (var j = 0, k = eles[i].className.split(/s+/g), l = k.length; j < l; j++) {
                        if (k[j] == claaName) {
                            arr.push(eles[i]);
                            break;
                        }
                    }
                }
                return arr;
            }
    

      

  • 相关阅读:
    C语言寒假大作战04
    C语言寒假大作战03
    C语言寒假大作战02
    C语言寒假大作战01
    C语言I作业12—学期总结
    C语言I博客作业11
    C语言I博客作业10
    C语言I博客作业09
    C语言I博客作业08
    c语言||作业01
  • 原文地址:https://www.cnblogs.com/alphafly/p/4771893.html
Copyright © 2011-2022 走看看