Although there are some examples about this on the web, it does not seem to work correctly. I can\'t figure out the problem.
I have this simple html
Basically, there are two ways to set / update data attribute value, depends on your need. The difference is just, where the data saved,
If you use .data() it will be saved in local variable called data_user, and its not visible upon element inspection,
If you use .attr() it will be publicly visible.
Much clearer explanation on this comment