Filter divs by data-attr containing string

前端 未结 4 1138
醉酒成梦
醉酒成梦 2021-01-18 17:21

How to filter a number of divs based on what they have in their custom data attribute using jQuery? The problem is that the attribute can have more than 1 value

4条回答
  •  爱一瞬间的悲伤
    2021-01-18 17:37

    To find the elements whose data-size attribute contain the string "small" you simply do this:

    $(".size[data-size*='small']");
    

提交回复
热议问题