Attribute Contains Prefix Selector [name|="value"]

jQuery('[attribute|="value"]')

attribute
An attribute name.
attribute:属性名称

value
An attribute value. Can be either an unquoted single word or a quoted string.
value:属性值。引号是可选的。

Description: 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.

Example:
Finds all links with an hreflang attribute that is english.
例子:查找所有hreflang属性为english的链接。
<!DOCTYPE html>
<html>
<head>
  <style>
a { display: inline-block; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
 
  <a href="example.html" hreflang="en">Some text</a>

  <a href="example.html" hreflang="en-UK">Some other text</a>

  <a href="example.html" hreflang="english">will not be outlined</a>
 
<script>
$('a[hreflang|="en"]').css('border','3px dotted green');
</script>

</body>
</html>

你可能感兴趣的:(jquery)