简体   繁体   中英

Show hide animate

I have the following show/hide function:

    // Show/hide filters on mobile //
$("#openMobileFilters").click(function(){   
    showOrHideFilter(true);
});
$(".closeFilters").click(function(){
    showOrHideFilter(false);         
}); 

function showOrHideFilter(show) {
    $("#results-container, .navbar-inverse" ).toggleClass( "hidden-xs", show );
    $("#filter-column").toggleClass("hidden-xs", !show); 
}

I wanted to add animation when the class is toggled. Something like:

.animate({ width: 'hide' });

I was unsure of how to combine this into the function?

Many thanks

try to modify your function like this:

function showOrHideFilter(show) {
    $("#results-container, .navbar-inverse" ).toggleClass( "hidden-xs", show );
    $("#filter-column").toggleClass("hidden-xs", !show); 
        if (show){
            $(this).animate({ width: 'hide' });
        }
}

Hope it was helpfull.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM