jQuery [attribute|=value] Selector
Example
Select all <p> elements with a title attribute starting with "Tomorrow":
$("p[title|='Tomorrow']")
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".
YouTip