Question

I'm using some pretty simple .toggleClass() with animation of 1 second.Everything works fine,except the animation. I'm finding this really funny.

Look at my fiddle!

$(function(){

 $('#main_button').click(function(){
 $('#one, #two, #three, #four').toggleClass("width", 1000);
 return false;
});
});
Was it helpful?

Solution

JQuery UI extends toggleClass to allow for animations, but the default JQuery .toogleClass() won't animate. You need to include JQuery UI in your fiddle.

OTHER TIPS

$(function(){

 $('#main_button').click(function(){
 $('#one, #two, #three, #four').animate({'width' :'toggle'}, 1000);
 return false;
});
});
$(function(){

         $('#main_button').click(function(){
         $('#one, #two, #three, #four').slideToggle({'width' :'toggle'}, 
        1000);
          return false;
          });
        });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top