JavaScript Tutorial Series 43:dom object's DataSet Property mode

Source: Internet
Author: User

1 special ways to set properties for DOM:

The DataSet property of the DOM object gets the properties defined by the Data-xxx method

Since we often need to customize properties on labels to store data or state, it is easy to confuse custom attributes with HTML specification attributes if you are working in a traditional way that is cumbersome and unfamiliar with HTML specifications. For more convenient and efficient implementation of this demand, We can use the DataSet property

2using the DataSet property of the Dom object, three points to note when manipulating custom properties:1 when defining attributes on a label, prefix data-

2 when you get/set the value of a property defined by data-in JS, you get/set through the dataset

// HTML<div id= "box" data-index= "0" i= "0" ></div>//jsvar box = document.getElementById (' box '// Returns an object containing all the properties defined on the current label with data- //  Returns the value of the Data-index

JavaScript Tutorial Series 43:dom object's DataSet Property mode

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.