2017-06-02 35 views

回答

1

書籤W3C Document Object Model Core - 作爲一個來源,它是一樣好,因爲它得到。

getAttribute是一個由Element接口實現的方法。來自W3C,

getAttribute按名稱檢索屬性值。

getNamedItem是由NamedNodeMap interface執行的方法。再次來自W3C,

getNamedItem檢索由名稱指定的節點。

interface Attr : Node { 
    readonly attribute DOMString  name; 
    readonly attribute boolean   specified; 
    // Modified in DOM Level 1: 
      attribute DOMString  value; 
             // raises(DOMException) on setting 
}; 

我考慮的getAttribute是一個(巨大)便利方法:

而getNamedItem返回節點,例如,實施Attr interface一個目的顯然的getAttribute返回一個字符串。

相關問題