如何使用四种方法在JavaScript中获取带有data-*属性的标签元素值?
- 内容介绍
- 文章标签
- 相关推荐
本文共计622个文字,预计阅读时间需要3分钟。
目录 + 方式一:dataset + 方式二:getAttribute/setAttribute/removeAttribute + 方式三:jQuery.attr + 方式四:jQuery.data + 前言:标签上有两个属性 data-id 和 data-user-name,需要通过JS获取。
本文共计622个文字,预计阅读时间需要3分钟。
目录 + 方式一:dataset + 方式二:getAttribute/setAttribute/removeAttribute + 方式三:jQuery.attr + 方式四:jQuery.data + 前言:标签上有两个属性 data-id 和 data-user-name,需要通过JS获取。

