Brief Introduction: HTML5 data-* Can add custom attributes and values for tags, and such custom attributes and values can be obtained through JS, which is very convenient.
Code:
// Html code
<Tr TH: Each = "plan :$ {list}" TH: Id = "$ {plan. planid }"
TH: ATTR = "data-plan-status =$ {plan. planstatus}, data-name =$ {plan. planname }" >
<TD> </TD>
<TD> </TD>
</Tr>
// Js code value
<SCRIPT type = "text/JavaScript">
// Obtain the node of the tr row selected in the table. The active node is selected similar to the class selector.
VaR nodes = $ ('# table1'). datatable (). Rows (". Active"). nodes ();
VaR statusarray = new array ();
VaR namearray = new array ();
VaR idarray = new array ();
If (commnutil. notnull (nodes )){
For (VAR I = 0; I, nodes. length; I ++ ){
VaR planstatus = $ (nodes [I]). Data ('planstatus ') ;
VaR planname = $ (nodes [I]). Data ('name ') ;
VaR id = $ (nodes [I]). ATTR ('Id ');
Statusarray [I] = planstatus;
Namearray [I] = planname;
Idarray [I] = ID;
}
}
// Omitted later
</SCRIPT>
Note: The data-name value is the common value data ('name'), and the data-plan-status value must be data ('planstatus '), the first letter after the second symbol "-" is automatically converted into a hump (upper case), one of the new features of H5.
In addition, ATTR is used to set or obtain the value of an attribute. If a tag contains an attribute, JS directly obtains the value of this attribute. ATTR ('Property name'). If you want to set custom attributes for a tag, you can simply add ATTR = "data-XXX" to the tag.
New Features of H5 -*