JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

15.4.4 Attributes As Attr Nodes

The drawSparkline() function in the above examples is fictitious, but Example 21-13 draws sparklines marked up like this using theelement.

15.4.4 Attributes As Attr Nodes

There is one more way to work with the attributes of an Element. The Node type defines an attributes property. This property is null for any nodes that are not Element objects. For Element objects, attributes is a read-only array-like object that represents all the attributes of the element. The attributes object is live in the way that NodeLists are. It can be indexed numerically, which means that you can enumerate all the attributes of an element. And it can also be indexed by attribute name:

document.body.attributes[0] // The first attribute of theelt document.body.attributes.bgcolor // The bgcolor attribute of theelt document.body.attributes["ONLOAD"] // The onload attribute of theelt

The values obtained when you index the attributesobject are Attr objects. Attr objects are a specialized kind of Node but are never really used like one. The name and value properties of an Attr return the name and value of the attribute.

友情链接It题库(| 版权归yishouce.com所有| 友链等可联系|粤ICP备16001685号-1