Element.getElementsByTagNameNS()

La méthode Element.getElementsByTagNameNS() renvoie un objet HTMLCollection avec le nom de balise donné appartenant à l'espace de noms donné. Elle est semblable à la méthode Document.getElementsByTagNameNS mais cette dernière recherche sur l'ensemble du document tandis que getElementsByTagNameNS() recherche parmi les descendants de l'élément courant.

Syntaxe

elements = element.getElementsByTagNameNS(namespaceURI,localName);

Paramètres

namespaceURI
L'URI de l'espace de noms des éléments à rechercher (cf. namespaceURI). Par exemple, si vous recherchez des éléments XHTML, utilisez l'URI d'espace de noms XHTML, http://www.w3.org/1999/xhtml.
localName
Le nom local des éléments à rechercher ou la valeur spéciale "*" (correspondant à tous les éléments). Voir Node.localName.

Valeur de retour

Une collection HTMLCollection des éléments trouvés, dans l'ordre d'apparition dans l'arbre du DOM.

Exemples

// vérifie l'alignement d'une série de cellules d'un tableau dans un document XHTML. 
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") { 
    // saisit les données 
  }
}

Spécifications

Spécification État Commentaires
DOM
La définition de 'Element.getElementsByTagNameNS()' dans cette spécification.
Standard évolutif Modification du type de la valeur de retour : passage de NodeList à HTMLCollection.
Document Object Model (DOM) Level 3 Core Specification
La définition de 'Element.getElementsByTagNameNS()' dans cette spécification.
Obsolete Aucune modification depuis Document Object Model (DOM) Level 2 Core Specification.
Document Object Model (DOM) Level 2 Core Specification
La définition de 'Element.getElementsByTagNameNS()' dans cette spécification.
Obsolete Définition initiale.

Compatibilité des navigateurs

Update compatibility data on GitHub
OrdinateurMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariWebview AndroidChrome pour AndroidFirefox pour AndroidOpera pour AndroidSafari sur iOSSamsung Internet
getElementsByTagNameNSChrome Support complet 1
Notes
Support complet 1
Notes
Notes Initially, this method was returning a NodeList; it was then changed to reflect the spec change.
Edge Support complet 12Firefox Support complet Oui
Notes
Support complet Oui
Notes
Notes The behavior of element.getElementsByTagNameNS changed between Firefox 3.5 and Firefox 3.6. In Firefox 3.5 and before, this function would automatically case-fold any queries so that a search for "foo" would match "Foo" or "foo". In Firefox 3.6 and later this function is now case-sensitive so that a query for "foo" will only match "foo" and not "Foo". For more background on this, please see the comment from Henri Sivonen about the change. You can also look at the relevant part of the standard, which states which parts of the API are case-sensitive and which parts aren't.
Notes Prior to Firefox 19, this method was returning a NodeList; it was then changed to reflects the spec change.
IE Support complet 5.5Opera Support complet Oui
Notes
Support complet Oui
Notes
Notes Initially, this method was returning a NodeList; it was then changed to reflect the spec change.
Safari Support complet 6
Notes
Support complet 6
Notes
Notes Initially, this method was returning a NodeList; it was then changed to reflect the spec change.
WebView Android Support complet OuiChrome Android Support complet OuiFirefox Android Support complet Oui
Notes
Support complet Oui
Notes
Notes The behavior of element.getElementsByTagNameNS changed between Firefox 3.5 and Firefox 3.6. In Firefox 3.5 and before, this function would automatically case-fold any queries so that a search for "foo" would match "Foo" or "foo". In Firefox 3.6 and later this function is now case-sensitive so that a query for "foo" will only match "foo" and not "Foo". For more background on this, please see the comment from Henri Sivonen about the change. You can also look at the relevant part of the standard, which states which parts of the API are case-sensitive and which parts aren't.
Notes Prior to Firefox 19, this method was returning a NodeList; it was then changed to reflects the spec change.
Opera Android Support complet OuiSafari iOS Support complet OuiSamsung Internet Android Support complet Oui
getElementsByTagNameNS(*)Chrome Support complet 1Edge Support complet OuiFirefox Support complet OuiIE Support complet 6Opera Support complet OuiSafari Support complet OuiWebView Android Support complet OuiChrome Android Support complet 18Firefox Android Support complet Oui
Notes
Support complet Oui
Notes
Notes The behavior of element.getElementsByTagNameNS changed between Firefox 3.5 and Firefox 3.6. In Firefox 3.5 and before, this function would automatically case-fold any queries so that a search for "foo" would match "Foo" or "foo". In Firefox 3.6 and later this function is now case-sensitive so that a query for "foo" will only match "foo" and not "Foo". For more background on this, please see the comment from Henri Sivonen about the change. You can also look at the relevant part of the standard, which states which parts of the API are case-sensitive and which parts aren't.
Notes Prior to Firefox 19, this method was returning a NodeList; it was then changed to reflects the spec change.
Opera Android Support complet OuiSafari iOS Support complet OuiSamsung Internet Android Support complet 1.0

Légende

Support complet  
Support complet
Voir les notes d'implémentation.
Voir les notes d'implémentation.