Can't update data-attribute value

后端 未结 9 1567
北海茫月
北海茫月 2020-11-27 17:11

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

         


        
9条回答
  •  伪装坚强ぢ
    2020-11-27 17:35

    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

提交回复
热议问题