如何在 jQuery 选择器中使用 .not()?
jqueryweb developmentfront end technology
.not() 用于选择除指定元素之外的所有 <p> 元素。
示例
您可以尝试运行以下代码来学习如何在 jQuery 选择器中使用 .not()。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p:not(.myclass)").css("background-color", "red");
});
</script>
</head>
<body>
<h1>Heading</h1>
<p class="myclass">This is demo text.</p>
<p>This is another text.</p>
</body>
</html>

