多重屬性選擇器 [name=”value”][name2=”value2″]


attributeMultiple 選擇器

說明: 符合所有指定屬性篩選器的元素。

  • 新增版本: 1.0jQuery( "[attributeFilter1][attributeFilter2][attributeFilterN]" )

    attributeFilter1: 屬性篩選器。

    attributeFilter2: 另一個屬性篩選器,進一步縮小選擇範圍

    attributeFilterN: 必要時可使用更多屬性篩選器

範例

找出具有 id 屬性且 name 屬性以 man 結尾的所有輸入,並設定其值。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>attributeMultiple demo</title>
<script src="https://code.jquery.com/jquery-3.7.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>

示範