zoukankan      html  css  js  c++  java
  • document

    预备知识:childNodes:返回一个元素的子节点

    document: 一个最顶层虚拟节点:他有两个子节点: <!DOCTYPE html>  

                                                                            <html lang="en">

          

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
        html{border: 1px solid red;}
        body{border: 1px solid #000;}
        .div1{100px;height:100px;background:green;}
        </style>
    </head>
    <body>
    这是body
    <div class="div1">
        
    </div>
        <script>
        window.onload=function(){
            console.log("document.childNodes[0]"+":"+document.childNodes[0]);
            console.log("document.childNodes[0].tagName"+":"+document.childNodes[0].tagName);
            console.log("document.childNodes[1].tagName"+":"+document.childNodes[1].tagName);
    document.body.onclick
    =function(){ console.log("点击body"); } /*document.html.onclick=function(){ //没有document.html console.log(点击html); }*/ document.onclick=function(){ console.log("点击document"); } } </script> </body> </html>

    以上可以看出 document html body 的范围

    Document 对象

     每个载入浏览器的 HTML 文档都会成为 Document 对象。

     Document 对象使我们可以从脚本中对 HTML 页面中的所有元素进行访问。

     Document 对象是 Window 对象的一部分,可通过 window.document 属性对其进行访问

    get...方法其他元素也可以用,继承?
     

  • 相关阅读:
    LIS(最长的序列)和LCS(最长公共子)总结
    SVN最有效的方法打基线
    SRM 638 Div2
    poj 2038 Team Rankings 枚举排列
    BZOJ 2809 APIO2012 dispatching Treap+启示式合并 / 可并堆
    Java中的工具类和新特性
    微信公众平台PHP开发
    全国各大 oj 分类题集...
    语言处理程序
    Android开发
  • 原文地址:https://www.cnblogs.com/everwangJS/p/4492218.html
Copyright © 2011-2022 走看看