Element.setAttributeNS()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
setAttributeNS añade un nuevo atributo o cambia el valor de un atributo con el namespace dado y el nombre.
Sintaxis
js
elemento.setAttributeNS(namespace, nombre, valor);
namespace
es un string especificando el namespace del atributo.name es un string identificando el atributo a ser puesto.
value es el string del valor deseado del nuevo atributo.
Ejemplo
js
var d = document.getElementById("d1");
d.setAttributeNS("http://www.mozilla.org/ns/specialspace", "align", "center");
Especificaciones
Specification |
---|
DOM # ref-for-dom-element-setattributens① |
Compatibilidad con navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
setAttributeNS |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.