我有一个可以更改 div 内容的函数。我想同时淡出和滑动,然后更改内容。然后是淡入和滑落。从现在的样子来看确实没什么问题。它只是不是淡出和淡入。我只是好奇如何做到这一点。我可以添加和删除类,这会影响我猜的不透明度。但我想知道单独使用 jQuery 是否可以实现这一点。
function swiperGetNew(title, moh, text) {
$('#frontpage_blog-swiper_info').find('article').slideUp(function() {
$(this).find('h2').text(title);
$(this).find('h3').text(moh);
$(this).find('p').text(text);
$(this).slideDown();
})
}
我尝试过制作 .animate,但我无法理解它。 我认为这应该有效,但事实并非如此。
$('#frontpage_blog-swiper_info').find('article').slideUp();
$('#frontpage_blog-swiper_info').find('article').fadeOut(function() {
$(this).find('h2').text(title);
$(this).find('h3').text(moh);
$(this).find('p').text(text);
$(this).fadeIn();
$(this).slideDown();
})
最佳答案
尝试
$(this).animate({opacity: 'hide', height: 'hide'}, 'slow');
注意:如果您需要它,动画将显示为:
$('#myDiv').animate({opacity: 'show', height: 'show'}, 'slow');
如果您希望一个效果在其他效果结束后开始,请尝试使用回调:
$('#element').fadeOut('slow',function(){
$(this).slideUp('fast');
});
但不要认为这看起来很好。
关于jQuery fadeOut 和 SlideUp,然后 fadeIn 和 SlideDown,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21748377/