JSFiddle - React, Tailwind, and code Playground

HTML

<div id="ball"></div>

CSS

#ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: red;
}

JavaScript

//смена цвета шара
ball.onclick = function() {
  let x = Math.floor(Math.random() * 255);
  let y = Math.floor(Math.random() * 255);
  let z = Math.floor(Math.random() * 255);
  
  ball.style.backgroundColor = "rgb(" + x + ", " + y + ", " + z + ")";
}