javascript原生API總結

來源:互聯網
上載者:User

標籤:des   style   ar   sp   for   java   strong   on   bs   

一、尋找:

  getElementById() 方法返回帶有指定 ID 的元素(唯一):

  getElementsByTagName() 返回包含帶有指定標籤名稱的所有元素的節點列表(集合/節點數組)。

  getElementsByClassName() 返回包含帶有指定類名的所有元素的節點列表(集合/節點數組)。

 

  parentNode - 節點(元素)的父節點

  childNodes - 節點(元素)的子節點

  元素的首個子項目(firstChild)

  元素的最後一個子項目(lastChild)

  attributes - 節點(元素)的屬性節點

  document.documentElement - 全部文檔

  document.body - 文檔的主體

二、建立:

  createAttribute() 建立屬性節點。

  createElement() 建立元素節點。

  createTextNode() 建立文本節點。

  var oFragment = document.createDocumentFragment(); 建立文本片段

三、插入:

  appendChild() 把新的子節點添加到指定節點。

  replaceChild() 替換子節點。parent.replaceChild(para,child);

  insertBefore() 在指定的子節點前面插入新的子節點。parent.insertBefore(new,child)

四、刪除:

  removeChild() 刪除子節點。

五、操作:

  getAttribute() 返回指定的屬性值。

  setAttribute() 把指定屬性設定或修改為指定的值。

  innerHTML - 節點(元素)的文本值

  nodeName 屬性規定節點的名稱。

  nodeValue 屬性規定節點的值。

  nodeType 屬性返回節點的類型。nodeType 是唯讀。

元素類型 NodeType
元素 1
屬性 2
文本 3
注釋 8
文檔 9

 

 

javascript原生API總結

聯繫我們

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