I have a custom data-attribute set by default:
data-equipment="0"
If i change it with jquery using .data()
$(this).data("equipment", 10)
and then use the getAttribute()
this.getAttribute("data-equipment")
i get the old value (0) and not the new one (10). But if i use
$(this).data("equipment")
i get the new value (10).
Is this supposed to work like this or am i missing something?
Thanks!
.data()
doesn't truly support data attributes. It just grabs the value from the attribute then uses its own data storage to hold it without ever updating the attribute. I personally wouldn't use jQuery's.data()
for this. – Marplot