The previous example is skipped for listening when the image is ready (loaded) before displaying it.
If you want fadeOut / In:
$("img").on("click", function(){
var $this = $(this);
$this.animate({
opacity: 0
}, {
complete: function(){
$this.on("load", function(){
$this.animate({
opacity: 1
});
});
$this.attr("src", "newurl");
}
});
});
If you want blur, just change the opacity in the animation block:
transform: "blur(0px)"and transform: "blur(10px)"
you may have to add a prefix for browsers without Chrome.
source
share