Skip to content

Using .data() in jQuery

Issue Description

Trying to dynamically update a data attribute on a element using the .data('attr') method doesn’t get picked up, despite the DOM being updated initially.

Affected Browsers

  • all

Issue Type

How to Fix the Issue

Instead of using .data('attr') to get, and then change, the attribute you should use .attr('data-attr'); instead.

References

Reference Description

Reference Link

Stack Overflow Comments

Back to Issues List