Attribute Ends With 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 ending exactly with a given string. The comparison is case sensitive.
描述:选择指定属性的属性值是以给定的字符串结尾的所有元素。字符串比较区分大小写。

Example:
Finds all inputs with an attribute name that ends with 'letter' and puts text in them.
例子:查找name属性的属性值中以'letter'结尾的所有input元素,然后输入一些文字。
<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <input name="newsletter" />

  <input name="milkman" />
  <input name="jobletter" />
<script>$('input[name$="letter"]').val('a letter');</script>

</body>
</html>

你可能感兴趣的:(jquery)