Attribute Ends With Selector [name$="value"]

attributeEndsWith ( attribute, value ) version added: 1.0

  • attribute
    Type: String
    An attribute name.
  • value
    Type: String
    An attribute value. Can be either an unquoted single word or a quoted string.

Description: Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.

Examples:

Example: Finds all inputs with an attribute name that ends with 'letter' and puts text in them.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>css demo</title>

  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
  

<input name="newsletter">
<input name="milkman">
<input name="jobletter">

<script>

$( "input[name$='letter']" ).val( "a letter" );

</script>

  
</body>
</html>

Demo: