JSFiddle - React, Tailwind, and code Playground

by gRoberts

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<a href="https://www.google.co.uk" class="element">Test</a>
<a href="#2" class="element">Test</a>
<a href="#3" class="element">Test</a>
<a href="#4" class="element">Test</a>

SCSS

.element {
  width: 100%;
  height: 250px;
  justify-content: center;
  align-items: center;
  display: flex;
  position: relative;
  background: rgba(0,0,0,0.3);
  & + .element {
    margin-top: 10px;
  }
  
  &:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: red;
    opacity: 0;
    pointer-events: none;
  }
  
  &.active {
    &:before {
      opacity: 1;
      pointer-events: all;
    }
  }
}

JavaScript

$(document).on('touchstart mouseover', '.element', function() {
	$('.element').not(this).removeClass('active');
	$(this).addClass('active');
});