tadam logo
Did you find an error in the text?
Select this with mouse and press
Ctrl + Enter
Xhtml.co.il Check Spelling
Orphus system

[attribute|=value]

Attribute Contains Prefix Selector [attribute|=value]

Arguments

jQuery('[attribute|=value]')

version added: 1.0
attribute
An attribute name.
value
An attribute value. Quotes are optional.

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.
$('a[hreflang|=en]').css('border','3px dotted green');
The output of the code above will be:

Full source

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
  <script type="text/javascript" language="javascript">
  $(document).ready(function(){
     $('a[hreflang|=en]').css('border','3px dotted green');    
  });
  </script>
</head>
<body>
   <a href="example.html" hreflang="en">Some text with hreflang="en"</a> 
   <a href="example.html" hreflang="en-UK">Some other text with hreflang="en-UK"</a>
   <a href="example.html" hreflang="ru">Some other text with hreflang="ru"</a>
</body>
</html>                   
Was this information helpful?
   

Comments