Attach data to a <div> element, then retrieve the data:
The data() method attaches data to, or gets data from, selected elements.
Tip: To remove data, use the removeData() method.
Returns attached data from a selected element.
| Parameter | Description |
|---|---|
| name | Optional. Specifies the name of data to retrieve. If no name is specified, this method will return all stored data for the element as an object |
Attach data to selected elements.
| Parameter | Description |
|---|---|
| name | Required. Specifies the name of data to set |
| value | Required. Specifies the value of data to set |
Attach data to selected elements using an object with name/value pairs.
| Parameter | Description |
|---|---|
| object | Required. Specifies an object containing name/value pairs |
Your message has been sent to W3Schools.