zoukankan      html  css  js  c++  java
  • [HTML5] DOM Nodes Explained

    import './assets/css/style.css';
    
    const app = document.getElementById('app');
    app.innerHTML = '<h1>JavaScript DOM</h1>';
    
    
    // <html>
    console.log(document.documentElement);
    console.dir(document.documentElement);
    
    // <head>
    console.dir(document.head);
    
    // <body>
    console.dir(document.body);
    
    // retrieve the constructor name
    console.log(document.body.constructor.name);
    
    // looking at the prototype chain
    console.log(document.body instanceof HTMLBodyElement);
    console.log(document.body instanceof HTMLElement);
    console.log(document.body instanceof Element);
    console.log(document.body instanceof Node);
    console.log(document.body instanceof EventTarget);
    
    /*
      - NodeTypes
      1: Element
      2: Attribute
      3: Text
      4: CDATASection
      5: EntityReference
      6: Entity
      7: ProcessingInstruction
      8: Comment
      9: Document
      10: DocumentType
      11: DocumentFragment
      12: Notation
    */
    
    console.log(document.body.nodeType); // 1
    console.log(document.nodeType); // 9
    
    // nodeName for any Node types
    console.log(document.nodeName); // #document
    // tagName for any Element types
    console.log(document.tagName); //undefined
  • 相关阅读:
    ubuntu 14.04 LTS 163更新源
    Windows 2008R2 修改SID
    ubuntu14 使用rsync远程备份文件
    vim常用
    Ubuntu创建lvm
    Windows 迁移本地用户配置文件到域用户
    Linux scp使用
    Centos 7 修改网卡名称、静态IP
    Axel多线程工具安装
    testlink 1.9.19安装
  • 原文地址:https://www.cnblogs.com/Answer1215/p/12508336.html
Copyright © 2011-2022 走看看