zoukankan      html  css  js  c++  java
  • 节点的层次关系

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script type="text/javascript" src="new_file.js"></script>
    </head>
    <body>
        <input type="radio" name="" /><input type="text" name="" /><div id="box">
        <span>我是span1</span>
        <span>我是span2</span></div><input type="text" name="" />
        <script type="text/javascript">
            
    // 怎么获取前面所有的兄弟元素??????
    
    
            var oDiv = $("box");
            // 1.获取所有的子节点 childNodes
            console.log( oDiv.innerText );
            // 2.获取第一个子节点 firstChild
            console.log( oDiv.firstChild );
            // 3.获取最后一个子节点 lastChild
            console.log( oDiv.lastChild );
            // 4.获取父节点  parentNode
            console.log( oDiv.parentNode );
        
            ////////////////兄弟关系/////////////////
            // 5.获取前一个兄弟节点  previousSibling
            console.log( oDiv.previousSibling );
            // 6.获取下一个兄弟节点  nextSibling
            console.log( oDiv.nextSibling );
        
            ///////////////////根节点/////////////////
            console.log( oDiv.ownerDocument );
            
            
        </script>
    </body>
    </html>
  • 相关阅读:
    小希的迷宫
    不下降序列
    Stones on the Table
    glsl之纹理演示
    glsl之多重纹理演示
    6.12
    这狗日的生活
    小楼一夜听春雨,天下谁人不识君?
    lua 调用C/C++
    D3DFVF_XYZ和D3DFVF_XYZRHW的区别
  • 原文地址:https://www.cnblogs.com/f-z-g-boke/p/9621615.html
Copyright © 2011-2022 走看看