Switch button text

by Chris Ball

HTML

<button id="clickMe">
    <span>Click Me</span>
</button>

JavaScript

$('body').on('click','#clickMe',function(e){
    e.preventDefault();
    var $this = $(this);
    var $span = $this.find('span');
    var $text = $span.text();
     $span.fadeOut(180)
        .text("Clicked")      
        .fadeIn(180)
        .delay(1200)
        .fadeOut(180, function() {
            $(this).text($text)
        })
        .fadeIn(180); 
    
});