YouTip LogoYouTip

Sel Attribute Prefix Value

jQuery [attribute|=value] Selector

jQuery Selectors jQuery Selectors

Example

Select all <p> elements with a title attribute starting with "Tomorrow":

$("p[title|='Tomorrow']")

Try it yourself Β»


Definition and Usage

The [attribute|=value] selector selects each element with the specified attribute, where the value is exactly the specified string (like "en") or starts with the specified string followed by a hyphen (like "en-us").

Tip: This selector is often used for language attributes.


Syntax

$("[attribute|='value']")
Parameter Description
attribute Required. Specifies the attribute to search for.
value Required. Specifies the string that the attribute value must start with.

More Examples

Handling the language attribute

This example selects all <a> elements with an hreflang attribute starting with the value "en".

jQuery Selectors jQuery Selectors

← Event BlurSel Attribute Notequal Value β†’