HTML data - attributes will be automatically pulled in to . Store arbitrary data associated with the matched elements or return the value at the named data store for the first element in the set of matched elements. Keep in min that if you adjust the data - attribute dynamically via JavaScript it will NOT be reflected in the data() jQuery function. This article is adapted from Using data attributes in JavaScript and CSS on . The jQuery Mobile framework uses HTMLdata - attributes to allow for markup- based initialization and configuration of widgets.
These attributes are completely. The data () method attaches data to, or gets data from, selected elements. Tip: To remove data , use the removeData() method.
Instea jQuery has an internal data store that holds the data assigned to each . In vanilla JavaScript setting a data attribute of an element is done with the generic setAttribute() method. A data attribute is exactly that: a custom attribute that stores data. With jQuery , I want to find the element based on a data - attribute value.
After finding, I want to update that element, with the data - attribute.
