小白教程
所有教程
关于
Search
172.69.6.234
172.69.6.234
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Sel attribute contains value”的源代码
本页内容
上一节:
Sel_attribute_beginning_value
下一节:
Sel_attribute_contains_string_value
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:[attribute~=value]}}[[Category:jquery ref selectors|46]] = jQuery [attribute~=value] 选择器 = [[jquery ref selectors|jQuery 选择器]] 选取所有带有包含单词 "nation" 的 name 属性的 <input> 元素: <sample title="" desc="" lang="html" hererun="1"> $("input[name~='nation']") </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("input[name~='nation']").css("background-color","yellow");}); </script> </head> <body> <input name ="nationality" type="text" value="Chinese"> <input name="nation" type="text" value="English"> <input name="country" type="text" value="Germany"> <input name="anothernation" type="text" value="Norwegian"> <p>选取所有 name 属性包含 'nation' 单词的 input 元素。</p> <p><b>注意</b>: 选取的是'nation' 单词,而不是以 "nation" 开头或结束的单词(例如 "nationality" 和 "anothernation")。 </body> </html> </run> == 定义和用法 == [attribute~=value] 选择器选取每个带有指定属性且值包含指定单词的元素。 '''提示:'''单词可以包含空格。 == 语法 == <pre> $("[attribute~='value']")</pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | attribute | 必需。规定要查找的属性。 |- | value | 必需。规定值要包含的单词。 |} [[jquery ref selectors|jQuery 选择器]]
返回至“
Sel attribute contains value
”。
上一节:
Sel_attribute_beginning_value
下一节:
Sel_attribute_contains_string_value