當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JQuery 多個屬性同時選擇[name="value"][name2="value2"]用法及代碼示例

用法
attributeMultiple selector

說明:匹配與所有指定屬性過濾器匹配的元素。

  • 添加的版本:1.0jQuery( "[attributeFilter1][attributeFilter2][attributeFilterN]" )

    attributeFilter1:屬性過濾器。

    attributeFilter2:另一個屬性過濾器,更加減少了選擇

    attributeFilterN: 盡可能多的屬性過濾器

例子:

查找具有 id 屬性且 name 屬性以 man 結尾的所有輸入並設置值。

<!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>

演示:

相關用法


注:本文由純淨天空篩選整理自jquery.com大神的英文原創作品 多個屬性同時選擇[name="value"][name2="value2"]。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。