Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery ^= vs |=. Unnecessary?

jQuery attributeContainsPrefix [name^="value"]

vs

attributeStartsWith [name|="value"]

What the practical difference?

like image 968
Vitaly Batonov Avatar asked Dec 28 '22 21:12

Vitaly Batonov


1 Answers

Attribute Contains Prefix Selector in the Manual:

Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-).

This selector was introduced into the CSS specification to handle language attributes.

That means it will match en and en-US but will not match entanglement like the other would. And this is not only good for languages, but anything that can be prefixed.

like image 178
kapa Avatar answered Jan 09 '23 11:01

kapa