Multiple Attribute Selector [name=value][name2=value2] in JQuery

 

Sample:

version added: 1.0jQuery(‘[attributeFilter1][attributeFilter2][attributeFilterN]’)

  • attributeFilter1
    An attribute filter.
    attributeFilter2
    Another attribute filter, reducing the selection even more
    attributeFilterN
    As many more attribute filters as necessary

Example:

Finds all inputs that have an id attribute and whose name attribute ends with man and sets the value.

<!DOCTYPE html>
<html>
<head>
  <script src="/scripts/jquery-1.4.js"></script>
</head>
<body>
	<input id="man-news" name="man-news" />

  <input name="milkman" />
  <input id="letterman" name="new-letterman" />
  <input name="newmilk" />
<script>$("input[id][name$='man']").val("only this one");</script>
</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *