Attribute contains prefix ([foo|=bar])

Description and Syntax

$('[foo|=bar]')

selects all elements that have the foo attribute with a value either equal to bar, or beginning with bar and a hyphen (-).

Examples

  • $('[id|=hello]') selects all elements with an id of hello or an id that begins with hello-
  • $('a[hreflang|=en]') selects all <a> elements with a hreflang value of en or beginning with en-
  • $('a[hreflang|=en]') matches <a href="example.html" hreflang="en">Some text</a> as well as <a href="example.html" hreflang="en-UK">Some text</a>.