问题:
Is there an easy and straight-forward method to select elements based on their data
attribute? 是否有一种简单而直接的方法来根据其data
属性选择元素? For example, select all anchors that has data attribute named customerID
which has value of 22
. 例如,选择所有具有名为customerID
数据属性,其值为22
锚。
I am kind of hesitant to use rel
or other attributes to store such information, but I find it much harder to select an element based on what data is stored in it. 我有点犹豫使用rel
或其他属性来存储此类信息,但是我发现很难根据其中存储的数据来选择元素。
解决方案:
参考一: https://stackoom.com/question/ARAx/通过数据属性选择元素参考二: https://oldbug.net/q/ARAx/Selecting-element-by-data-attribute
来源:oschina
链接:https://my.oschina.net/u/4428122/blog/4316254