Converting data-* attributes to an object

后端 未结 4 1328
太阳男子
太阳男子 2021-01-01 12:24

I\'m playing around with the attr-data-* attributes of HTML5 and the corresponding javascript dataset

I\'m doing alot of dynamic form processing, so I end up getting

4条回答
  •  Happy的楠姐
    2021-01-01 12:47

    You can use Object.assign

    Object.assign({}, element.dataset) 
    

    For browsers that doesn't support Object.assign you can use polyfill

提交回复
热议问题