Attribute Equals 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 exactly equal to a certain value.
描述:查找属性的属性值等于给定的属性值的所有元素。

Example:
Finds all inputs with a value of "Hot Fuzz" and changes the text of the next
sibling span.
例子:查找所有value属性等于"Hot Fuzz"的input元素然后改变它的兄弟元素span的文字内容。

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <div>
    <label>
      <input type="radio" name="newsletter" value="Hot Fuzz" />
      <span>name?</span>
    </label>
  </div>
  <div>
    <label>
      <input type="radio" name="newsletter" value="Cold Fusion" />
      <span>value?</span>
    </label>
  </div>
  <div>
    <label>
      <input type="radio" name="newsletter" value="Evil Plans" />
      <span>value?</span>
    </label>
  </div>
<script>$('input[value="Hot Fuzz"]').next().text(" Hot Fuzz");</script>

</body>
</html>

你可能感兴趣的:(jquery)