JSFiddle - React, Tailwind, and code Playground

by liormb

HTML

<body>
    <div id='element'></div>
</body>

CSS

div {
    width: 200px;
    height: 200px;
    background-color: red;
}

JavaScript

// Option I: Working
/* 
$('#element').mousedown(function(e){
    $(this).css({ background:'blue' });
});
*/


// Option II: Not Working
function modifyColor(){
    $el.css({ background:'green' });
}
 
var $el = document.getElementById('element');
$el.addEventListener("onmousedown", modifyColor, false);