How to change the expand direction on .toggle()?
Asked Answered
M

4

9

I am using .toggle() jquery for expand/collapse.

Do you know how to change the expand/collapse direction from bottom to top instead of top-left to bottom-right? I am no jquery expert, I found the demo and use these codes...

Here is my working file: http://www.streetlightministries.ca/2013 - and click "Times & Location" on the top right corner. You will see it expanding from top-left to bottom-right. I rather to have it expand from bottom to top.

I would be really appreciate if you are able to help me out!

Thanks

Markusmarl answered 28/5, 2013 at 19:34 Comment(0)
S
13

For starters, I would use .slideToggle() instead of .toggle(). It just a simple collapse and expand. Try that out first and see if you like that result better.

Stablish answered 28/5, 2013 at 19:40 Comment(0)
C
5

You are looking for slideToggle.

If you're lucky, you'll just need to change toggle() to slideToggle().

Carabin answered 28/5, 2013 at 19:38 Comment(2)
I tried but it didn't work, I think it is because the toggle() and slideToggle() use different jquery. Thanks for your help tho!Markusmarl
Well i don't get how this didnt work but the other answer worked since it's exactly the same, but anyway, it worked and that's what matter!Eye
L
2

Try this

$('blah').toggle('drop', {direction: 'right'}, 150)
Landwaiter answered 20/2, 2014 at 15:12 Comment(0)
H
0

Try this, using the callback property

<script type="text/javascript">
            $(document).ready(function () {                        
                $(".scCollapAnchor").click(function () {
                    $('.iiColapsable').toggle("slide",
                        {
                            direction: 'up',
                            complete: function () {
                                if ($('#spanCollapsable').hasClass('glyphicon-chevron-down')) {
                                    $('#spanCollapsable').removeClass('glyphicon-chevron-down');
                                    $('#spanCollapsable').addClass('glyphicon-chevron-up');
                                }
                                else {
                                    $('#spanCollapsable').removeClass('glyphicon-chevron-up');
                                    $('#spanCollapsable').addClass('glyphicon-chevron-down');
                                }
                            }
                        }, 400);
                });
            });
        </script>
Helvetia answered 14/4, 2016 at 20:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.