jQuery addClass example

Change class name on click in jQuery

HTML

<div class="overlay-container">

  <div class="overlay">
    <button>button</button>
  </div>
</div>

CSS

.overlay-container{
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: #000;
  display: flex;
  justify-content: center;
  align-items: center;
}
.overlay{
  background-color: #fff;
width: 300px;
height: 300px;
  text-align: center;
}

JavaScript

$(".overlay-container").click(function(event) {
if( $(event.target).hasClass('overlay-container')){
 	alert("removed");
  $( this ).removeClass('active');
 }
});