JQuery选择器
Input元素中 对name属性进行筛选
$( "input[name!='newsletter']" )
$("input").not("[name=newsletter]")
<!doctype html>
<html lang="en">
<head>
<Meta charset="utf-8">
<title>attributeNotEqual demo</title>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<div>
<input type="radio" name="newsletter" value="Hot Fuzz">
<span>name is newsletter</span>
</div>
<div>
<input type="radio" value="Cold Fusion">
<span>no name</span>
</div>
<div>
<input type="radio" name="accept" value="Evil Plans">
<span>name is accept</span>
</div>
<script>
$( "input[name!='newsletter']" ).next().append( "<b>; not newsletter</b>" );
</script>
</body>
</html>
选择属性取反操作
选取form表单中,div元素id值不为a的子元素中的input
$( "form div:not(#a) input" )
$( "form div:not([id='a']) input" )
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="utf-8">
<title>attributeNotEqual demo</title>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<form class="">
<div id="a" class="form-floating mb-3">
<input type="email" class="form-control rounded-4" id="floatingInput" placeholder="name@example.com">
<label for="floatingInput">Email address</label>
</div>
<div id="b" class="form-floating mb-3">
<input type="password" class="form-control rounded-4" id="floatingPassword" placeholder="Password">
<label for="floatingPassword">Password</label>
</div>
</form>
<script>
$( "form div:not(#a) input" ).css("background-color","pink");
</script>
</body>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。