jquery toggle slide from left to right and back

后端 未结 5 1687
既然无缘
既然无缘 2021-02-05 19:00

I have a \"Menu\" button on the left hand side of the page and once selected I have a div containing the menu items show. I then have another button that can be selected to hid

5条回答
  •  孤城傲影
    2021-02-05 19:03

    There is no such method as slideLeft() and slideRight() which looks like slideUp() and slideDown(), but you can simulate these effects using jQuery’s animate() function.

    HTML Code:

    Lorem ipsum.

    JQuery Code:

      $(document).ready(function(){
        var DivWidth = $(".text").width();
        $(".left").click(function(){
          $(".text").animate({
            width: 0
          });
        });
        $(".right").click(function(){
          $(".text").animate({
            width: DivWidth
          });
        });
      });
    

    You can see an example here: How to slide toggle a DIV from Left to Right?

提交回复
热议问题