Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery data do not match dom attribute

I have an weird issue with jquery data function. Here is the fiddle

As you can see I update the active data but I cannot see the dom data-active attribute value change, although I re-query the active data, It writes the changed value. $.data() do not update the attribute on the dom when I inspect it.

like image 842
px5x2 Avatar asked Feb 17 '23 05:02

px5x2


1 Answers

jQuery data api does not depends on the element attribute although it uses data-<key> to fetch the initial value if it is available.

jQuery uses an internal javascript object to maintain the data value of objects

If you want to update the attribute then you will have to use .attr('data-<key>', '<value>')

like image 129
Arun P Johny Avatar answered Feb 19 '23 03:02

Arun P Johny