Skip to content Skip to sidebar Skip to footer

Jquery UI Add Class With Animation Does't Work

See my jsfiddle (apologies for putting the javascript into the html body but somehow it did not work placing it in the javascript field): http://jsfiddle.net/40mga4vy/ I want to ch

Solution 1:

You need to define transition rule in CSS. Then background image will change with animation effect:

#wallpaper {
    /* ... */
    transition: all .4s ease;
}

Demo: http://jsfiddle.net/40mga4vy/2/


Solution 2:

I have now an animation on image change. I first let the Jquery change the image, then set the opacity to 0 and than with the jquery animate() I animate the opacity to 1.

I this is you new script:

 function changeBackground() {
    $('#wallpaper').removeClass();

    $("#wallpaper").addClass("wallpaper_" +      $("#select_category").val()).css('opacity','0').animate({opacity:'1'});
 };

Take a look at the fiddle


Post a Comment for "Jquery UI Add Class With Animation Does't Work"