Mozilla.com

  1. MDC
  2. Main Page
  3. DOM
  4. element.getElementsByTagNameNS
Redirected from En/GetElementsByTagNameNS

element.getElementsByTagNameNS

« Gecko DOM Reference

Summary

Returns a list of elements with the given tag name belonging to the given namespace.

Syntax

elements = element.getElementsByTagNameNS(namespaceURI, localName) 
  • elements is a live NodeList of found elements in the order they appear in the tree.
  • element is the element from where the search should start. Note that only the descendants of this element are included in the search, not the node itself.
  • namespaceURI is the namespace URI of elements to look for (see element.namespaceURI). For example, if you need to look for XHTML elements, use the XHTML namespace URI, http://www.w3.org/1999/xhtml.
  • localName is either the local name of elements to look for or the special value "*", which matches all elements (see element.localName).

Example

// check the alignment on a number of cells in a table in an XHTML document. 
var table = document.getElementById("forecast-table"); 
var cells = table.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "td"); 
for (var i = 0; i < cells.length; i++) { 
    var axis = cells[i].getAttribute("axis"); 
    if (axis == "year") { 
        // grab the data 
    }
}

Notes

element.getElementsByTagNameNS is similar to document.getElementsByTagNameNS , except that its search is restricted to descendants of the specified element.

Page last modified 23:02, 21 Jul 2007 by Mgjbot

Files (0)