<breadcrumbs></breadcrumbs>
== Summary ==ๆฆ่ฆ
<code>setAttributeNodeNS</code> adds a new attribute node with the specified namespace and name. setAttributeNodeNS
ใฏๆๅฎใฎๅๅ็ฉบ้ใจๅๅใงๆฐใใๅฑๆงใใผใใ่ฟฝๅ ใใพใใ== Syntax ==
ๆงๆ
replacedAttr = element.setAttributeNodeNS(attributeNode)
* <code>replacedAttr</code> is the replaced attribute node, if any, returned by this function. * <code>attributeNode</code> is an <code>Attr</code> node.
replacedAttr
ใฏใใใฎ้ขๆฐใซใใฃใฆ่ฟใใใใฎใงใใใฐใ็ฝฎใๆใใใใๅฑๆงใใผใใงใใattributeNode
ใฏAttr
ใใผใใงใ.
Example
// <div id="one" special-align="utterleft">one</div> // <div id="two">two</div> var myns = "http://www.mozilla.org/ns/specialspace"; var d1 = document.getElementById("one"); var d2 = document.getElementById("two"); var a = d1.getAttributeNodeNS(myns, "special-align"); d2.setAttributeNodeNS(a); alert(d2.attributes[1].value) // returns: `utterleft'
ๆณจ่จ
If the specified attribute already exists on the element, then that attribute is replaced with the new one and the replaced one is returned. ๆๅฎใฎๅฑๆงใๆขใซๅญๅจใใฆใใใจใใฏใใใฎๅฑๆงๆฐใใใใฎใซ็ฝฎใๆใใใใ็ฝฎใๆใใใใใใฎใๆปใๅคใจใใฆ่ฟใใใพใใ
DOM ใกใฝใใใฏ่ฆ็ด ใฎๅฑๆงใๅใๆฑใใพใใ
ๅๅ็ฉบ้ใซ็ก้ขไฟใ ๆใไธ่ฌ็ใซไฝฟ็จใใใใกใฝใใ |
ๅๅ็ฉบ้ใซ้ๅฎใใใๅคๆฐ (DOM Level 2) |
Attr ใใผใใ็ดๆฅๆฑใ DOM ใฌใใซ 1 ใฎใกใฝใใ(ใปใจใใฉไฝฟ็จใใใชใ) |
Attr ใใผใใ็ดๆฅๆฑใ DOM ใฌใใซ 2 ๅๅ็ฉบ้ใซ้ๅฎใใใใกใฝใใ(ใปใจใใฉไฝฟ็จใใใชใ) |
---|---|---|---|
setAttribute (DOM 1) |
setAttributeNS |
setAttributeNode |
setAttributeNodeNS |
getAttribute (DOM 1) |
getAttributeNS |
getAttributeNode |
getAttributeNodeNS |
hasAttribute (DOM 2) |
hasAttributeNS |
- | - |
removeAttribute (DOM 1) |
removeAttributeNS |
removeAttributeNode |
- |