html dom的理解

來源:互聯網
上載者:User

標籤:

DOM (Document Object Model)文件物件模型,將html文檔以及文檔中的內容轉換成node介面,以便外部(如js)操作(如修改html內容等)。

  node節點的類型:

    DocumentType(如下)、

    Document(一個文檔對應一個對象)、

    Element(html、head、body等)、

    Text(html文檔中,標籤之間,如下的div1和divc1之間雖然看著沒有什麼,其實是有一個內容為‘‘的Text節點)

    Attribute(標籤的屬性,如id=”div1“就是一個屬性節點)

    Comment(注釋)

    DocumentFragment (沒見過)

 

<!DOCTYPE html>                  DocumentType   <html>    <head>        <meta charset="utf-8" />        <title></title>    </head>    <body>        <div id="div1">            <div class="divc1">                <div id="div">                    文本節點                </div>                <!--注釋--></div>        </div>    </body></html>

DOM是瀏覽器對外提供的一個編程介面,包含的介面中我們要用到的關係如下:

  NodeList

  HTMCollection

  Node

    Document

    Element

    Attr

  Attr的使用是在Element中有個attributes屬性,返回一個數組,裡面的對象都是Attr。

  這裡需要注意的是Node和Element連個介面,我們在前端開發中使用js操作html標籤對應的對象,使用的都是Element介面的屬性和方法(自己這樣認為)。

 

更多見:http://www.w3help.org/zh-cn/causes/SD9024

html dom的理解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.