Remove another jQuery selection from the selected elements - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:not

Description

Remove another jQuery selection from the selected elements

Demo Code

ResultView the demo in separate window

<!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($("div p.intro")).css("color", "red");
});// ww w  . jav  a2  s.c om
</script>
</head>
<body>

<div style="border:1px solid black;">
  This is a div element
  <h1>Welcome to My Homepage</h1>
  <p>test</p>
  <p class="intro">test(this p element will be removed from the group).</p>
  <p>test</p>
</div>

<p class="intro">here</p>
<p>This p element is outside the div element.</p>

</body>
</html>

Related Tutorials