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


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

Consider this snippet of html:

<li id="person1" data-city="Boston, New York, San Fransisco"> Person name 1 </li> <li id="person1" data-city="Los Angeles, New York, Washington"> Person name 2 </li>

What is the best way in jQuery to select all persons with "New York" in the data-city attribute?


<strike>even though i don't see your html,</strike> it should be:

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


  • How to Divide an array on c#?
  • Cut the background to expose the layer below
  • Automatically associate new Sonar project with custom quality profile and quality gate
  • Parse a date string in a specific locale (not timezone!)
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • Using jQuery closest() method with class selector
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • HTML download movie download link
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • When should I choose bucket sort over other sorting algorithms?
  • ORA-29908: missing primary invocation for ancillary operator
  • jQuery tmpl and DataLink beta
  • Jquery - Jquery Wysiwyg return html as a string
  • How to get next/previous record number?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Unanticipated behavior
  • Compare two NSDates in iPhone
  • How to get icons for entities from eclipse?
  • How to disable jQuery.jplayer autoplay?
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Proper way to use connect-multiparty with express.js?
  • Benchmarking RAM performance - UWP and C#
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • Load html files in TinyMce
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • How do you join a server to an Active Directory (domain)?
  • Angular 2 constructor injection vs direct access
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • How to stop GridView from loading again when I press back button?
  • How does Linux kernel interrupt the application?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • JaxB to read class hierarchy
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal