我正在寻找一种从div中的HTML淡入另一HTML而不褪色为白色(至div的背景色)的方法,就像我在此示例中所做的那样:
positionNumber变量只是一个带有数字的int(例如3)。
function changeContent(positionNumber) {
$('.banner-content-wrapper').fadeOut('fast', function() {
var contentHtml = $('.slidercontent#' + positionNumber).html();
$('.banner-content-wrapper').hide().fadeIn(1000).html(contentHtml);
});
}
此示例通过先淡入白色来实现完全相同的功能,但这不是我想要的:
Why doesn't jquery fadeIn() work with .html()?
我想直接从一种HTML淡入另一种HTML。我一直无法在Stack Overflow上找到任何示例来说明如何做到这一点。我知道这不是有效的代码,但我正在寻找这样的东西:
$('。banner-content-wrapper')。fadeToHtml(contentHtml);
如何直接褪色?
最佳答案
为什么要使用fadeOut / fadeIn-为什么不隐藏/显示
function changeContent(positionNumber) {
$('.banner-content-wrapper').hide('fast', function() {
var contentHtml = $('.slidercontent#' + positionNumber).html();
$('.banner-content-wrapper').hide().html(contentHtml).show();
});
}
我还没有测试过-只是基于您引用的示例的建议