getElementsByTagNameNS

< dom‎ | methods
Jump to: navigation, search

getElementsByTagNameNS


W3C Recommendation

Summary

Gets a live HTMLCollection of the elements with the specified tag name and namespace.

Method of dom/document

Syntax

var elements = document.getElementsByTagNameNS(namespaceURI, localName);

Parameters

namespaceURI

Data-type: String


The namespace URI that defines the desired elements or an asterisk (*) to match all namespaces with the document, or null.


localName

Data-type: String


The name of the desired element or an asterisk (*) to match all elements with the specified namespace.

Return Value

Returns an object of type Object.

A live HTMLCollection of elements.

Needs Examples: This section should include examples.

Usage

This method should not be used. For a more performant alternative, see the notes.

Use this method to get a live list of elements with a specified name and namespace.

Notes

  • For performance reasons, querySelectorAll is preferred, because it gets a static list.
  • This method returns a live element list that gets updated whenever an element is added or removed from the document, this has performance implications and may result in unexpected errors (removing elements within a for loop while caching the length of the collection).
  • If namespaces are irrelevant in the context, getElementsByTagName can be used (but it is also not recommended, see the first two notes).


Related specifications

Specification Status Related Changes
Document Object Model (DOM) Level 3 Core Recommendation Section 1.4
Document Object Model (DOM) Level 2 Core Recommendation Section 1.2
DOM Living Standard Section 6.5, 6.8

Compatibility

Desktop

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? ? ? ? ?

Mobile

Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic support ? ? ? ? ? ? ? ?

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]