Liam Liam - 2 years ago 460
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?

Answer Source

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

toggleClass( class, [duration] )

Docs + DEMO

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download