NamedNodeMap

NamedNodeMap interface represents a collection of Attr objects. Objects inside a NamedNodeMap are not in any particular order, unlike NodeList , although they may be accessed by an index as in an array.

A NamedNodeMap object is live and will thus be auto-updated if changes are made to its contents internally or elsewhere.

Although called NamedNodeMap , this interface doesn't deal with Node objects but with Attr objects, which were originally a specialized class of Node , and still are in some implementations.

特性

This interface doesn't inherit any property.

NamedNodeMap.length 只读
Returns the amount of objects in the map.

方法

This interface doesn't inherit any method.

NamedNodeMap.getNamedItem()
返回 Attr , corresponding to the given name.
NamedNodeMap.setNamedItem()
Replaces, or adds, the Attr identified in the map by the given name.
NamedNodeMap.removeNamedItem()
移除 Attr identified by the given map.
NamedNodeMap.item()
返回 Attr at the given index, or null if the index is higher or equal to the number of nodes.
NamedNodeMap.getNamedItemNS()
返回 Attr identified by a namespace and related local name.
NamedNodeMap.setNamedItemNS()
Replaces, or adds, the Attr identified in the map by the given namespace and related local name.
NamedNodeMap.removeNamedItemNS()
移除 Attr identified by the given namespace and related local name.

规范

规范 状态 Comment
DOM
The definition of 'NamedNodeMap' in that specification.
实时标准 Deals with Attr instead of Node
Document Object Model (DOM) Level 3 Core Specification
The definition of 'NamedNodeMap' in that specification.
Obsolete No change from Document Object Model (DOM) Level 2 Core Specification
Document Object Model (DOM) Level 2 Core Specification
The definition of 'NamedNodeMap' in that specification.
Obsolete 添加 getNamedItemNS() , setNamedItemNS() and removeNamedItemNS()
Document Object Model (DOM) Level 1 Specification
The definition of 'NamedNodeMap' in that specification.
Obsolete 初始定义

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
NamedNodeMap Chrome Yes Edge 12 Firefox 34
34
不支持 22 — 34
Alternate Name
Alternate Name Uses the non-standard name: mozNamedAttrMap
不支持 ? — 22
IE Yes Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34
34
不支持 22 — 34
Alternate Name
Alternate Name Uses the non-standard name: mozNamedAttrMap
不支持 ? — 22
Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
getNamedItem Chrome Yes Edge 12 Firefox 34 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
getNamedItemNS Chrome Yes Edge 12 Firefox 34 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
item Chrome Yes Edge 12 Firefox 34 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
length Chrome Yes Edge 12 Firefox 34 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
removeNamedItem Chrome Yes Edge 12 Firefox 34 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
removeNamedItemNS Chrome Yes Edge 12 Firefox 34 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
setNamedItem Chrome Yes Edge 12 Firefox 34 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
setNamedItemNS Chrome Yes Edge 12 Firefox 34 IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android 34 Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持
完整支持
兼容性未知
兼容性未知
使用非标名称。

另请参阅