jquery toggle slide from left to right and back

后端 未结 5 1630
既然无缘
既然无缘 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:00

    Hide #categories initially

    #categories {
        display: none;
    }
    

    and then, using JQuery UI, animate the Menu slowly

    var duration = 'slow';
    
    $('#cat_icon').click(function () {
        $('#cat_icon').hide(duration, function() {
            $('#categories').show('slide', {direction: 'left'}, duration);});
    });
    $('.panel_title').click(function () {
        $('#categories').hide('slide', {direction: 'left'}, duration, function() {
            $('#cat_icon').show(duration);});
    });
    

    JSFiddle

    You can use any time in milliseconds as well

    var duration = 2000;
    

    If you want to hide on class='panel_item' too, select both panel_title and panel_item

    $('.panel_title,.panel_item').click(function () {
        $('#categories').hide('slide', {direction: 'left'}, duration, function() {
            $('#cat_icon').show(duration);});
    });
    

    JSFiddle

提交回复
热议问题