Attribute Ends With Selector [name$=value]

attributeEndsWith selector

version added: 1.0jQuery('[attribute$=value]')

  • attribute
    一个属性名.
    value
    一个属性值,引号是可选的.

描述: 选择指定属性是以给定值结尾的元素。这个比较是区分大小写的。

Example:

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

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <input name="newsletter" />

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

</body>
</html>

Demo:

jQuery 1.6 API 中文版Clove整理、修订