Get data-attribute jquery vs javascript

后端 未结 1 1183
一向
一向 2020-12-14 05:48

I have a custom data-attribute set by default:

data-equipment=\"0\"

If i change it with jquery using .data()

$(t

相关标签:
1条回答
  • 2020-12-14 06:20

    .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.

    0 讨论(0)
提交回复
热议问题