码迷,mamicode.com
首页 > Web开发 > 详细

[HTML5] DOM Nodes Explained

时间:2020-03-17 08:10:29      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:for   attribute   tar   ret   ase   instr   ext   class   str   

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

 

[HTML5] DOM Nodes Explained

标签:for   attribute   tar   ret   ase   instr   ext   class   str   

原文地址:https://www.cnblogs.com/Answer1215/p/12508336.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!