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
原文地址:https://www.cnblogs.com/Answer1215/p/12508336.html
时间: 2024-10-12 08:01:26