MENU
Processing Attributes
About Attributes
RESETRUNFULL
RESETRUNFULL
<!DOCTYPE html><html>
<head></head><body>
<p>About Attributes</p>
<script>
var p = document.querySelector("p");
console.log(p.hasAttributes()); // false
p.toggleAttribute("contenteditable")
console.log(p.hasAttribute("contenteditable")); // true
p.setAttribute("id","myP");
console.log(p.getAttribute("id")); // myP
var a = p.attributes; // NamedNodeMap
console.log(a[0]); // contenteditable=""
console.log(a["contenteditable"]); //contenteditable=""
console.log(a.id); // id="myP"
... an Attr
console.log(a.id.name); // id
console.log(a.id.value); // myP
console.log(a.id.prefix); // null
… unless in x:id="…"
</script></body></html>