<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
.block {
  width: 200px;
  height: 200px;
  background-color: red;
  margin: 5px;
}

.block_active {
  background-color: green;
}
$(".block").click(function(){
  $(".block").removeClass("block_active");
  $(this).addClass("block_active");
})

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js