问题:
I would like to know what selectors are available for these data attributes that come with HTML5. 我想知道哪些选择器可用于HTML5附带的这些数据属性。
Taking this piece of HTML as an example: 以这段HTML为例:
<ul data-group="Companies">
<li data-company="Microsoft"></li>
<li data-company="Google"></li>
<li data-company ="Facebook"></li>
</ul>
Are there selectors to get: 是否有选择器:
- All elements with
data-company="Microsoft"
below"Companies"
所有带有data-company="Microsoft"
元素都在"Companies"
之下 - All elements with
data-company!="Microsoft"
below"Companies"
所有带有data-company!="Microsoft"
元素都在"Companies"
之下 - In other cases is it possible to use other selectors like "contains, less than, greater than, etc...". 在其他情况下,可以使用其他选择器,如“包含,小于,大于等......”。
解决方案:
参考一: https://stackoom.com/question/HOh4/使用HTML-的自定义数据属性的jQuery选择器参考二: https://oldbug.net/q/HOh4/jQuery-selectors-on-custom-data-attributes-using-HTML5
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4396832