Attribute Equals Selector [name=value]

attributeEquals selector

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

  • attribute
    An attribute name.
    value
    An attribute value. Quotes are optional.

Description: Selects elements that have the specified attribute with a value exactly equal to a certain value.

Example:

Finds all inputs with name 'newsletter' and changes the text of the span next to it.

<!DOCTYPE html>
<html>
<head>
  <script src="https://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
	<div>

    <input type="radio" name="newsletter" value="Hot Fuzz" />
    <span>name?</span>

  </div>
  <div>
    <input type="radio" name="newsletters" value="Cold Fusion" />

    <span>name?</span>
  </div>
  <div>
    <input type="radio" name="accept" value="Evil Plans" />

    <span>name?</span>
  </div>
<script>$("input[name='newsletter']").next().text(" is newsletter");</script>
</body>
</html>

Demo: