Get data-attribute jquery vs javascript Get data-attribute jquery vs javascript javascript javascript

Get data-attribute jquery vs javascript


.data() doesn't operate on data attributes but in internal jQuery cache. Initially if no cache record is found, the data is read from a corresponding data- attribute if one exists, but that is the end of their co-operation.

If it operated on attributes, it would be useless for its purpose because attribute values must be strings.