JQuery data selector not updating with .data

前端 未结 2 558
失恋的感觉
失恋的感觉 2020-12-01 10:05

Basically if I have a div loaded onto a page with a data-test attribute and change the value of it with jquery\'s .data(\'test\') I can no longer s

2条回答
  •  生来不讨喜
    2020-12-01 10:38

    That's because i think that .data() use a special cache object inside jQuery to store data (in fact you can evens store object or complex tipes of data), if you check all the attributes are unchanged. If you want to change the attribute, use attr()

提交回复
热议问题