New Features of H5 -*

Source: Internet
Author: User

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 -*

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.