尝试在点击事件上动态添加新的隐藏 div,然后淡入此 div。
$('.param').on('click',function(event){
$(this).fadeOut('slow');
$('#bibox').append('<div style="display: none;" id="test"> Hello World!</div>');
$('#test').fadeIn('slow');
});
它将新的隐藏 div 正确添加到 #bibox 中,但保持隐藏状态。
最佳答案
试试这个:
$('.param').on('click',function(event){
$(this).fadeOut('slow');
var html = '<div style="display: none;" id="test"> Hello World!</div>';
$(html).hide().appendTo("#bibox").fadeIn('slow');
});
关于jquery - 新添加的元素上的 .fadeIn(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41616709/