This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

getAttributeNS

Summary

Returns the value of the content attribute within a specified namespace.

Method of dom/Elementdom/Element

Syntax

var attributeValue = element.getAttributeNS(namespaceURI, name);

Parameters

namespaceURI

Data-type
String

The namespace URI that defines the desired attribute, or a null value.

name

Data-type
String

The name of the desired attribute within the specified namespace.

Return Value

Returns an object of type StringString

The value of the content attribute, or null if it does not exist.

Examples

// Get the first div element in the page.
var element = document.querySelector("div");
// Continue only if the element exists.
if (element) {
 console.log("The value of the data-example attribute of the first div is " + element.getAttributeNS("html", "data-example"));
}

Syntax

Standards information

Related specifications

Document Object Model (DOM) Level 3 Core
Recommendation
Document Object Model (DOM) Level 2 Core
Recommendation
DOM
Living Standard

See also

Related pages

Attributions