any idea how to do this with jquery?
Not all solutions need a javascript solution, in this case a small change to your css is all you need.
.blue.active ~ .red { display:none; }
This states: when .blue is also .active then any siblings that are .red will be hidden.
You could also use
.blue.active + .red { display:none; }
if you know that .red is the very next element.
Example snippet:
$(".blue").click(function() { $(this).toggleClass("active"); });
.active { color: blue; }
.blue.active ~ .red { display:none }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='blue'>click me</div>
<div class='red'>changes</div>
As jquery uses css selectors (or close enough) you can do the same with jquery, or use another method to find the .red element, here's some examples where this
is the .blue element that's changing:
// must be the next element
$(this).toggleClass("active").next().toggle();
// next sibling
$(this).toggleClass("active").nextAll(".red").first().toggle();
// may also be before, but must still be a sibling
$(this).toggleClass("active").siblings(".red").toggle();
// red anywhere within the same "wrapper", so doesn't need to be a sibling
// (useful for tables where .wrapper = `tr`)
$(this).toggleClass("active").closest(".wrapper").find(".red").toggle();
// using the same as the css, if `this` is not the .blue element
// but will need additional code to reappear when .blue is not active
$(".blue.active ~ .red").hide();
$(".blue").click(function() {
$(this).toggleClass("active")
$(".red").show();
$(".blue.active ~ .red").hide();
});
.active {
color: blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='wrapper'>
<div class='blue'>click me</div>
<div class='red'>changes</div>
</div>