Why don't .not() have any affect?

Here is my code:

$('body').not('.specific_element').css('opacity','.3');
body{
  border: 1px solid;
}
.specific_element{
  border: 1px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>There are some texts</p>
<div class="specific_element">
  sth
</div>
<p>whatever</p>

All I’m trying to do is keeping the opacity of the element that has a red border to 1. I mean I want to apply opacity: .3 on everything except that specific element. How can I do that?



  1. Apply the opacity on the children of the container with the exception of the specific element
$('body').children().not('.specific_element').css('opacity','.3');
body{
  border: 1px solid;
}

.specific_element{
  border: 1px solid red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>There are some texts</p>
<div class="specific_element">
  sth
</div>
<p>whatever</p>

As @guradio suggested, it would be done by applying opacity on sibling of the specific element:

// Select all elements inside body except '.specific_element'
$('body *').not('.specific_element').css('opacity','.3');
$('*:not(*[class*="specific_element"])').css('opacity','.3');

on everything except that specific element.

Use * to select everything