当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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"]。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。