JSFiddle - React, Tailwind, and code Playground

HTML

<div class="red"></div>
<div class="green"></div>
<div class="blue"></div>

CSS

div {
  border: solid 1px grey;
  margin: 10px;
  height: 100px;
}

JavaScript

function Controller() {
  $('.red').on('click', function(e) {
  	$(this).css('background-color', 'red');
  });
}

Controller.prototype.changeColor = function() {
  $('.green').on('click', function(e) {
  	$(this).css('background-color', 'green');
  });
}

$('.blue').on('click', function(e) {
  $(this).css('background-color', 'blue');
});