JSFiddle - React, Tailwind, and code Playground
HTML
<div class="background">
<p>
Test
</p>
</div>
CSS
.toggle {
background-color: blue;
}
JavaScript
$(function() {
$(".background").on('mousedown touchstart', function() {
$(this).addClass("toggle");
}).on('mouseup mouseleave touchend', function() {
$(this).removeClass("toggle");
})
});