How to select elements with jQuery that have a certain value in a data attribute array

后端 未结 2 1970
南方客
南方客 2020-12-09 21:32

is there a way in jQuery to select elements that have a certain value in a data attribute array?

Consider this snippet of html:

  • 2条回答
    •  醉话见心
      2020-12-09 22:05

      try something like :

      $('li[data-city*="New York"]')
      

      Attribute Contains Selector [docs]

      jsfiddle example

    提交回复
    热议问题