JQuery show and hide div on mouse click (animate)

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

This is my HTML code:

Click Here
6条回答
  •  情深已故
    2020-12-01 04:25

    That .toggle() method was removed from jQuery in version 1.9. You can do this instead:

    $(document).ready(function() {
        $('#showmenu').click(function() {
                $('.menu').slideToggle("fast");
        });
    });
    

    Demo: http://jsfiddle.net/APA2S/1/

    ...but as with the code in your question that would slide up or down. To slide left or right you can do the following:

    $(document).ready(function() {
        $('#showmenu').click(function() {
             $('.menu').toggle("slide");
        });
    });
    

    Demo: http://jsfiddle.net/APA2S/2/

    Noting that this requires jQuery-UI's slide effect, but you added that tag to your question so I assume that is OK.

提交回复
热议问题