【发布时间】:2017-09-27 16:17:00
【问题描述】:
是否有一个负选择器? https://api.jquery.com/attribute-contains-selector/
例如,查询属性名称没有子字符串的所有输入 man
我尝试了明显但没有工作
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>attributeContains demo</title>
<script src="https://code.jquery.com/jquery-1.10.2.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>
未捕获的错误:语法错误,无法识别的表达式:
这个很接近https://api.jquery.com/attribute-not-equal-selector/但不相等,我想没有包含。
这个jQuery "not contains" selector 不起作用,因为我没有文本值,表单的创建方式在 value 属性内。
【问题讨论】:
标签: jquery