ToggleClass animate jQuery?

后端 未结 6 2049
生来不讨喜
生来不讨喜 2020-12-01 18:05

I have a section on my website that when a user clicks I would like it to expand, I\'m using the jQuery\'s toggleClass for this...

expandable: f         


        
6条回答
  •  佛祖请我去吃肉
    2020-12-01 18:17

    You should look at the toggle function found on jQuery. This will allow you to specify an easing method to define how the toggle works.

    slideToggle will only slide up and down, not left/right if that's what you are looking for.

    If you need the class to be toggled as well you can deifine that in the toggle function with a:

    $(this).closest('article').toggle('slow', function() {
        $(this).toggleClass('expanded');
    });
    

提交回复
热议问题