JQuery show and hide div on mouse click (animate)

后端 未结 6 1567
梦谈多话
梦谈多话 2020-12-01 04:04

This is my HTML code:

Click Here
6条回答
  •  孤街浪徒
    2020-12-01 04:29

    I would do something like this

    DEMO in JsBin: http://jsbin.com/ofiqur/1/

      Click Here
      
    

    and in jQuery as simple as

    var min = "-100px", // remember to set in css the same value
        max = "0px";
    
    $(function() {
      $("#showmenu").click(function() {
    
        if($(".menu").css("marginLeft") == min) // is it left?
          $(".menu").animate({ marginLeft: max }); // move right
        else
          $(".menu").animate({ marginLeft: min }); // move left
    
      });
    });
    

提交回复
热议问题