[英]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. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.