1 Get Tag Properties
Syntax: Element.getattribute (' property name ') returns the value of the corresponding property if NULL is not returned.
// HTML<div id= "box" index= "0" ></div>//jsvar box = document.getElementById (' box '); var value = Box.getattribute (' index '// 0
2Set the value of a custom property
Syntax: element.setattribute (' property name ', ' property's value ') returns undefined
// HTML<div id= "box" ></div>//jsvar box = document.getElementById (' box box.setattribute (' index ', 0//JS code after execution is complete.) changes in HTML tags <div id= "box "index=" 0 "></div>
3Remove the value of a custom property
Syntax: element.removeattribute (' property name ') returns undefined
// HTML<div id= "box" index= "0" ></div>//jsvar box = document.getElementById (' box '); Box.removeattribute (' index '//JS code after execution Changes in HTML tags <div id= "box" ></div>
Note:
1 These three methods of manipulating custom properties allow you to manipulate not only custom properties, but also properties in the HTML specification
2 sets the value of the property, which is eventually converted to the form of a string
JavaScript Tutorial Series 42: Actions on custom attributes on labels