jQuery delay between animations

后端 未结 1 1505
轮回少年
轮回少年 2020-12-22 12:39

I have two elements that shouldn\'t be active at the same time, so when one is toggled I fade the other out, however I would like to be able to fade the open element out and

相关标签:
1条回答
  • 2020-12-22 13:24

    Look at using the callback mechanism for fadeOut so you can chain the animations. The callback on the animation methods are called after the previous animation is complete.

     <script type="text/javascript">
        $(function() {
            $('#jlogin').click(function() {
               $('#reg').fadeOut('fast', function() {
                   $('#login').toggle('fast');
               });
            });
            $('#jreg').click(function() {
                $('#login').fadeOut( 'fast', function() {
                    $('#reg').toggle('fast');
                });
            });
         });
    </script>
    
    0 讨论(0)
提交回复
热议问题