zoukankan      html  css  js  c++  java
  • DOM操作

    function parent(e, n){
                var n = n || 1;
                while(n-- && e){
                    e = e.parentNode();
                }
                if(!e || e.nodeType != 1){
                    return null;
                }
                return e;
            }
            function sibling(e, n){
                while(e && n !==0){
                    if(n > 0){
                        if(e.nextElementSibling){
                            e = e.nextElementSibling;
                        } else{
                            for(e = e.nextSibling; e && e.nodeType !== 1; e = e.nextSibling);
                            /*empty loop*/
                        }
                        n--;
                    } else{
                        if(e.previousElementSibling){
                            e = e.previousElementSibling;
                        } else{
                            for(e = e.previousSibling; e && e.nodeType !== 1; e = e.previousSibling);
                            /*empty loop*/
                        }
                        n++
                    }
                }
                return e;
            }
            function textContent(element, value){
                var content = element.textContent;
                if(value !== undefined){
                    if(content !== undefined){
                        content = value;
                    } else{
                        element.innerText = value;
                    }
                } else{
                    if(content !== undefined){
                        return content;
                    } else{
                        return element.innerText;
                    }
                }
            }
            function textContent(e){
                var child, type, s = '';
                for(child = e.firstChild; child != null; child = child.nextSibling){
                    type = child.nodeType;
                    if(type == 3 || type == 4){
                        s += child.nodeValue;
                    } else if(type == 1){
                        s += textContent(e);
                    }
                }
                return s;
            }
  • 相关阅读:
    AUTOSAR-文档阅读
    前端 html
    http协议
    python格式化输出
    IO模型
    协程函数
    伟大的GIL
    苑之歌(进程,线程)
    python之模块导入和包
    任性计算器
  • 原文地址:https://www.cnblogs.com/fanhc/p/3284128.html
Copyright © 2011-2022 走看看