通过数据属性选择元素

一世执手 提交于 2020-07-24 13:46:46

问题:

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!