slideToggle JQuery right to left

后端 未结 9 686
再見小時候
再見小時候 2021-02-01 05:04

i\'m new in JQ i have this script i found on the internet and its do exactly what i need but i want the sliding will be from the right to the left how can i do it? please help

相关标签:
9条回答
  • 2021-02-01 05:08

    I would suggest you use the below css

    .showhideoverlay { 
      width: 100%;
      height: 100%;
      right: 0px;
      top: 0px;
      position: fixed;
      background: #000;
      opacity: 0.75;
    }
    

    You can then use a simple toggle function:

    $('a.open').click(function() {
      $('div.showhideoverlay').toggle("slow");
    });
    

    This will display the overlay menu from right to left. Alternatively, you can use the positioning for changing the effect from top or bottom, i.e. use bottom: 0; instead of top: 0; - you will see menu sliding from right-bottom corner.

    0 讨论(0)
  • 2021-02-01 05:09

    include Jquery and Jquery UI plugins and try this

     $("#LeftSidePane").toggle('slide','left',400);
    
    0 讨论(0)
  • 2021-02-01 05:16

    I know it's been a year since this was asked, but just for people that are going to visit this page I am posting my solution.

    By using what @Aldi Unanto suggested here is a more complete answer:

      jQuery('.show_hide').click(function(e) {
        e.preventDefault();
        if (jQuery('.slidingDiv').is(":visible") ) {
          jQuery('.slidingDiv').stop(true,true).hide("slide", { direction: "left" }, 200);
        } else {
          jQuery('.slidingDiv').stop(true,true).show("slide", { direction: "left" }, 200);
        }
      });
    

    First I prevent the link from doing anything on click. Then I add a check if the element is visible or not. When visible I hide it. When hidden I show it. You can change direction to left or right and duration from 200 ms to anything you like.

    Edit: I have also added

    .stop(true,true)
    

    in order to clearQueue and jumpToEnd. Read about jQuery stop here

    0 讨论(0)
  • 2021-02-01 05:22

    You can do this using additional effects as a part of jQuery-ui

    $('.show_hide').click(function () {
        $(".slidingDiv").toggle("slide");
    });
    

    Test Link

    0 讨论(0)
  • Please try this code

    $(this).animate({'width': 'toggle'});
    
    0 讨论(0)
  • 2021-02-01 05:26

    Try this

    $('.slidingDiv').toggle("slide", {direction: "right" }, 1000);
    
    0 讨论(0)
提交回复
热议问题