Attribute Equals Selector [name=”value”]

Attribute Equals Selector [name=”value”]

attributeEquals selector

Description: Selects elements that have the specified attribute with a value exactly equal to a certain value.

  • version added: 1.0jQuery( "[attribute='value']" )

    attribute: An attribute name.

    value: An attribute value. Can be either a valid identifier or a quoted string.

https://github.com/aspnet/jquery-validation-unobtrusive/blob/master/src/jquery.validate.unobtrusive.js#L242

 

$selector.find("[data-val=true]").each(function () {
                $jQval.unobtrusive.parseElement(this, true);
            });

 

 

 

Attribute Contains Selector [name*=”value”]

attributeContains selector

Description: Selects elements that have the specified attribute with a value containing a given substring.

  • version added: 1.0jQuery( "[attribute*='value']" )

    attribute: An attribute name.

    value: An attribute value. Can be either a valid identifier or a quoted string.

This is the most generous of the jQuery attribute selectors that match against a value. It will select an element if the selector's string appears anywhere within the element's attribute value. Compare this selector with the Attribute Contains Word selector (e.g. [attr~="word"]), which is more appropriate in many cases.

Example:

Finds all inputs with a name attribute that contains 'man' and sets the value with some text.

复制代码
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>attributeContains demo</title>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 
<input name="man-news">
<input name="milkman">
<input name="letterman2">
<input name="newmilk">
 
<script>
$( "input[name*='man']" ).val( "has man in it!" );
</script>
 
</body>
</html>
复制代码

只有前面三个input里面会有字符串"has man in it",第四个是没有的

 

 attribute-selectors

 

 

 

 

作者:Chuck Lu    GitHub    
posted @   ChuckLu  阅读(176)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2018-05-18 innerxml and outerxml
2017-05-18 查看以及改变文件的编码格式
2017-05-18 difference in physical path, root path, virutal path, relative virtual path, application path and aboslute path?
2017-05-18 Anatomy of an IIS7 configuration path
2017-05-18 Understanding IIS Bindings, Websites, Virtual Directories, and lastly Application Pools
2017-05-18 netsh http的使用
2016-05-18 string[][]和string[,] 以及 int[][]和int[,]
点击右上角即可分享
微信分享提示