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