Liam Liam - 1 year ago 264
Javascript Question

ToggleClass animate jQuery?

I have a section on my website that when a user clicks id like it to expand, Im using the jQuery toggleClass for this...

expandable: function(e) {
$(this).closest('article').toggleClass('expanded', 1000);

This is working fine, only Id like to somehow animate it? In chrome my article slowly grows to the new size, only in firefox it 'instantly' resizes itself with no animation, is there a way to have this animate?


jQuery UI extends the jQuery native toggleClass to take a second optional parameter: duration

toggleClass( class, [duration] )

Docs + DEMO