Multiple Attribute Selector Example

This tutorial explains how to multiple elements in jQuery . The multiple attribute selector selects multiple elements within a form. It matches all the specified attributes in the document and it specifies the multiple elements can be selected at once. The multiple attribute selectors can be used to refer to several attributes of an element or several times to the same element.

Description: Matches elements that match all of the specified attribute filters.

jQuery(“[attributeFilter][attributeFilter2][attributeFilterN]”)

attribute Filter 1: An attribute filter.

attribute Filter 2: Another attribute filter, reducing the selection even more

attribute Filter N: 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 lang="en">
<head>
   <meta charset="utf-8">
   <title>attributeMultiple demo</title>
   <script src="https://code.jquery.com/jquery-3.5.0.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>

Demo:

Leave a Reply

Your email address will not be published.