The main methods are as follows:
If the data attribute is an object (starting with "{") or an array (starting with '['), you can use jQuery.parseJSON to parse it into a string; it must follow the syntax of valid JSON, Include the property name in double quotes. If the value cannot be parsed as a JavaScript value, it will be retained as a string.
If you want to use the retrieved attribute value directly as a string, please use the attr() method.
The data-attribute is no longer accessed or changed after the first use of this data attribute (all data values are stored internally in jQuery).
If you call .data() without parameters, all data will be obtained in the form of JavaScript objects. This object can be safely stored in a variable, because once the new object is extracted, subsequent .data(obj) operations on the element will no longer affect this object. Additionally, manipulating this object directly is faster than calling .data() each time to set or get a value.