- 0133技术站
- 联系QQ:18840023
- QQ交流群

- 微信公众号

jQuery [attribute~=value] 选择器
定义和用法
[attribute~=value] 选择器选取每个带有指定属性且值包含指定单词的元素。
提示:单词可以包含空格。
语法
$("[attribute~='value']")
参数 | 描述 |
attribute | 必需。规定要查找的属性 |
value | 必需。规定值要包含的单词 |
<script> $(document).ready(function(){ $("input[name~='nation']").css("background-color","pink");}); </script> </head> <body> <input name ="nationality" type="text" value="Chinese"> <input name="nation" type="text" value="English"><br> <input name="country" type="text" value="Germany"> <input name="anothernation" type="text" value="Norwegian">
点击 "运行实例" 按钮查看在线实例
效果图:
推荐手册