JSFiddle - React, Tailwind, and code Playground

HTML

<div class="square">click me</div>

CSS

.square {
    background:red;
    height:100px;
    width:100px;
    cursor:pointer;
}

JavaScript

$('.square').click(function () {
        rotate($(this), -180, 1000);
    });

    function rotate(element, degrees, speed) {
        element.animate({
            borderSpacing: degrees
        }, {
            step: function (now, fx) {
                $(this).css('-webkit-transform', 'rotate(' + now + 'deg)');
                $(this).css('-moz-transform', 'rotate(' + now + 'deg)');
                $(this).css('transform', 'rotate(' + now + 'deg)');
            },
            duration: speed
        }, 'linear').promise().done(function () {
            alert("E");
        });
    }