JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div id="target3"></div>
</body>
CSS
#target3{
width:100px;
height:200px;
background:#555;
}
JavaScript
var style3=createElement('style');
style3.type="text/css";
var target3=document.getElementById('target3');
target3.addEventListener('click',function(){
style3.innerHTML='.target4{background-color:#444;}';
document.getElementsByTagName('head')[0].appendChild(style3);
target3.setAttribute('class','target4');
});