HOME / BLOG / BLOG-POST

How to Show or hide a div by using jQuery?

Show or hide a div by using jQuery

<!-- html code as example-->
<div class="login-form">...,</div>
<div class="signup-form">...,</div>
<div class="create-account-bar"><span class="msg1">Don't have account?</span><span class="msg2">Already have an account?</span> <span class="signup" >Sign Up</span><span class="signin" >Sign In</span></div>
<!--jQuery code-->
<script type="text/javascript">
  jQuery(document).ready(function($){
    $(".signup").click(function(){
        $(".login-form").hide();
  $(".msg1").hide();
  $(".msg2").show();
        $(".signup-form").show();
        $(".signin").show();
       $(this).hide();
    });
 
 $(".signin").click(function(){
        $(".login-form").show();
        $(".signup-form").hide();
        $(".signup").show();
  $(".msg1").show();
  $(".msg2").hide();
       $(this).hide();
    });

});

 


about authors

Sandip Das

Web Developer

Once a legend said “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler.



POST COMMENTS

Leave a Reply

Your email address will not be published. Required fields are marked *