DOM_節點層次_Document類型

來源:互聯網
上載者:User

標籤:

一、Document類型

nodeType: 9;

nodeName: ”#document”;

nodeValue: null;

parentValue: null;

ownerDocumet: null.

其他瀏覽器(除IE)可以訪問Document的建構函式與原型;

所有瀏覽器 (包括IE8 +)訪問 HTMLDocument 的建構函式與原型;

var html = document.documentElement;//<html>的引用——所有瀏覽器支援var body = document.body;//<body>的引用——所有瀏覽器支援

二、尋找元素 document.getElementById()  ||  documet.getElementByTagName   ||  documet.getElementByName

document.getElementById() —— 區分大小寫,IE8及更早不區分大小寫。

特殊情況:<input>  <textarea>  <button>  <select>

<input type="text" name="text1" value="textVaile">    <div id="text1"></div>

IE7   通過document.getElementById(“text1”) 返回input

其他瀏覽器   通過document.getElementById(“text1”) 返回div

 

documet.getElementByTagName() —— 不區分大小寫  返回一個HTMLCollection “動態”集合 類似NodeList;

<img src="a.gif" name="img">var imgName = document.getElementByTagName("img").namedItem("img");

documet.getElementByName() —— 返回一個HTMLCollection “動態”集合 類似NodeList;

其他HTMLCollection 對象:

document.anchors——所有帶name的<a>元素

document.images     document.forms     document.links

三、檢測瀏覽器支援給定名稱和版本的功能

var hasCss2 = document.implementation.hasFeature("CSS","2.0")

DOM_節點層次_Document類型

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.