JSFiddle - React, Tailwind, and code Playground

HTML

<div class="check1"></div>
<div class="check1"></div>
<div style="clear:both;"></div>
<div class="check1"></div>
<div class="check1"></div>

CSS

.check1 {
    width: 100px;
    height: 100px;
    border: 1px solid;
}

JavaScript

$('.check1').mousedown(function () {
    $(this).css('background-color', 'blue');
    flag = 1;
});
$('.check1').mouseup(function () {
    flag = 0;
});

$('.check1').mouseover(function () {
     
        $(this).css('background-color', 'red');
    
});