The random quote machine

For some reason the change of color in the background happens whenever I click the button. However, the animation part only happen if i load the page (or reload it)

In your click handler, you can put this:

    $(".quote-box").removeClass("run-animation");
    setTimeout(function(){
       $(".quote-box").addClass("run-animation");;
    },1);

It remove that CSS for the animation, then adds it back, after 1ms. I tried chaining them but it didn’t work. This works. Maybe someone smarter than me can come up with something more elegant.

1 Like