$(selector).not(criteria)
$(selector).not(function(index))
<!DOCTYPE html>
<html>
<head>
<style>
div{
font-size: 20px;
font-weight: bold;
}
</style>
<script src="/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
function fun(){
$(document).ready(function(){
$("p").not(".para").css({"background": "yellow"});
});
}
</script>
</head>
<body>
<h2> Welcome to the bianchenghao6.com </h2>
<h4> This is an example of using the jQuery's not() method. </h4>
<div id = "div1"> This is first div element. </div>
<p class = "para"> P1 with class = "para" </p>
<div id = "div2"> This is second div element. </div>
<p> P2. </p>
<p> P3. </p>
<p class = "para"> P4 with class = "para". Click the following button to see the effect. </p>
<button onclick = "fun()"> click me </button>
</body>
</html>
Welcome to the bianchenghao6.com
This is an example of using the jQuery's not() method.
P1 with class = "para"
P2.
P3.
P4 with class = "para". Click the following button to see the effect.
<!DOCTYPE html>
<html>
<head>
<style>
div{
font-size: 20px;
font-weight: bold;
}
</style>
<script src="/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
function fun(){
$(document).ready(function(){
$("p").not(function(index) {
if(index == 1 || index == 2){
return true;
}
}).css({"background": "yellow"});
});
}
</script>
</head>
<body>
<h2> Welcome to the bianchenghao6.com </h2>
<h4> This is an example of using the jQuery's not() method. </h4>
<div id = "div1"> This is first div element. </div>
<p class = "para"> P1 with class = "para" </p>
<div id = "div2"> This is second div element. </div>
<p> P2. </p>
<p> P3. </p>
<p class = "para"> P4 with class = "para". Click the following button to see the effect. </p>
<button onclick = "fun()"> click me </button>
</body>
</html>
Welcome to the bianchenghao6.com
This is an example of using the jQuery's not() method.
P1 with class = "para"
P2.
P3.
P4 with class = "para". Click the following button to see the effect.