Switch/toggle div (jQuery)

后端 未结 9 622
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 09:39

I wish to accomplish a fairly simple task (I hope!)

I got two div tags and one anchor tags, like this:

forgot p         


        
相关标签:
9条回答
  • 2020-12-01 10:30

    This is how I toggle two divs at the same time:

    $('#login-form, #recover-password').toggle();
    

    It works!

    0 讨论(0)
  • 2020-12-01 10:31

    Since one div is initially hidden, you can simply call toggle for both divs:

    <a href="javascript:void(0);" id="forgot-password">forgot password?</a>
    <div id="login-form">login form</div>
    
    <div id="recover-password" style="display:none;">recover password</div>
    
    <script type="text/javascript">
    $(function(){
      $('#forgot-password').click(function(){
         $('#login-form').toggle();
         $('#recover-password').toggle(); 
      });
    });
    </script>
    
    0 讨论(0)
  • 2020-12-01 10:31
    function toggling_fields_contact_bank(class_name) {
        jQuery("." + class_name).animate({
            height: 'toggle'
        });
    }
    
    0 讨论(0)
提交回复
热议问题