JSFiddle - React, Tailwind, and code Playground

by Dawid Karwat

HTML

<div id="kloc"></div>

CSS

#kloc {
    display: block;
    width:100px;
    height: 100px;
    background-color: #953;
    transition: 400ms linear;
}

JavaScript

var kloc = document.getElementById('kloc');
var nowyKolor = "red",
    orygKolor = kloc.style.backgroundColor,
    i = 0;

function funkcja() {
    if (this.style.backgroundColor == orygKolor) {
        this.style.backgroundColor = nowyKolor;
    } else {
        this.style.backgroundColor = orygKolor;
    }
     i += 20;
     this.style.transform = 'rotate('+i+'deg)';
}
kloc.onclick = funkcja;
kloc.onmouseover = funkcja;
kloc.onmouseout = funkcja;