HTML DOM Attributes length property
- Turbuwar ɗanarorin item()
- Ƙasancewa name
- Turbuwar ɗanarorin HTML DOM Attributes
definition and usage
length
attribute returns the number of nodes in NamedNodeMap.
length
attributes are read-only.
note:attributes of HTML elements are located in NamedNodeMap.
see also:
instance
example 1
get the number of attributes of an HTML element:
let num x = document.getElementById("myButton").attributes.length;
example 2
get all attribute names:
const nodeMap = document.getElementById("myButton").attributes; let text = ""; for (let i = 0; i < nodeMap.length; i++) { text += nodeMap[i].name + "<br>"; }
example 3
how many attributes does "myImg" have:
let num = document.getElementById("myImg").attributes.length;
example 4
get all attributes:
const nodeMap = document.getElementById("myImg").attributes; let text = ""; for (let i = 0; i < nodeMap.length; i++) { text += nodeMap[i].name + " = " + nodeMap[i].value + "<br>"; }
syntax
namednodemap.length
technical details
return value
number, representing the number of attribute nodes in nodemap.
browser support
attributes.length
ɗanarorin DOM Level 1 (1998) ɗanarorin.
Dukiyar ɗanarorin ɗanarorin ɗanarorin suka ɗauki su:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Gudanarwa | 9-11 | Gudanarwa | Gudanarwa | Gudanarwa | Gudanarwa |
- Turbuwar ɗanarorin item()
- Ƙasancewa name
- Turbuwar ɗanarorin HTML DOM Attributes