JSFiddle - React, Tailwind, and code Playground
HTML
<div id="bloco"></div>
CSS
#bloco {
width:50px;
height:50px;
background-color:blue;
}
JavaScript
(function($) {
$.fn.clickToggle = function(func1, func2) {
var funcs = [func1, func2];
this.data('toggleclicked', 0);
this.click(function() {
var data = $(this).data();
var tc = data.toggleclicked;
$.proxy(funcs[tc], this)();
data.toggleclicked = (tc + 1) % 2;
});
return this;
};
}(jQuery));
$('#bloco').clickToggle(function(){
$(this).css("background-color", "#666");
$(this).animate({"width":"400px"}, 1000);
}, function() {
$(this).css("background-color", "blue");
$(this).animate({"width":"50px"}, 1000);
});