Html5 custom data attributes, that is, data-* Custom Attributes-notes ., Html5data-
Html5 custom data attributes, that is, data-* Custom Attributes.
For example
<div data-last-value="43" data-hidden="true" data-options='{"name":"John"}'></div>
There are three methods to access and modify data:
1. Use the getAttribute setAttribute method, for example, div. getAttribute ("data-last-value ")
2. Use dataset attributes
Returns a set.
Div. dataset --> DOMStringMap {options: "{\" name \ ": \" John \ "}", hidden: "true", lastValue: "43 "}
Accessible, add, or delete
Div. dataset. hidden div. dataset. newAttr = "123" delete div. dataset. hidden
3. Use jquery's data method
. Data (key, value)
. Data (key, value)
. Data (obj) --> set multiple key-value pairs
. Data (key)
. Data (key)
. Data () --> Returns a set
JQuery automatically converts the returned value string to the corresponding data type.
For example, the above $ ("div"). data () --> {options: {"name": "John"}, hidden: true, lastValue: 43}
Note:For the dataset attribute and the data method of jQuery: if the data-attribute name contains a hyphen, for example, data-last-value, the hyphen will be removed, and convert it to a camper name. The previous attribute name should be lastValue after conversion.
Question about custom attributes of html tags
Does not affect html js. You can write n attributes.
You only need JS to get its value through xxx. getAttribute ("your written attribute ").
A small question about the jQuery UI framework: Where are the custom attributes of the following HTML elements defined?
The components you used above should be in the pop-up box. These parameters are all customized by jquery ui. These parameters will be mentioned in the api documentation, www.jeasyui.com/documentation/index.php, you can find the "dialog" link in the left navigation bar and you will see the relevant parameters. These attributes are not described in detail, but they are used in the instance, in addition, it can be seen from the literal meaning what the specific role is.