JSFiddle - React, Tailwind, and code Playground

HTML

<div id="foo"></div>

CSS

#foo{ width: 20px; height: 20px; background: #ccc;}
#bar{ width: 20px; height: 20px; background: #e22;}

JavaScript

$('#foo').live('click',function(){
        var $this = $(this);
        var ele = $this.clone();
        ele.html('<div id="bar">' + Math.random().toString(36) + '</div>');
        $this.fadeOut(100, "ease-out", function(){
            $this.replaceWith(ele);
            ele.hide().fadeIn(50, "ease-in");
        });
    });