我正在制作一个可以淡入淡出新闻的新闻板。当元素淡出时,内容会被删除,当它淡入时,会出现新的内容。这行得通,只是时机不对。应该只在旧内容消失时出现的新内容,在元素消失时出现。有没有办法等到这完成?
$(document).ready(function() {
var counter = 0;
var slides = ['<p>Track All of Your enemys Using The <span>Scout Tool!</span></p>',
'<p>Download powerups Using The <span>Pirate Tool!</span></p>',
'<p>Gather Badges To Attack others in <span>Raids!</span></p>',
'<p>Enjoy Orgainzing Your Profile <span>Join Now!</span></p>'];
$('#slide-left').click(function() {
$('#slide').fadeTo('fast', 0);
$('#slide p').remove();
if (counter > 0){counter --;}
$('#slide').append(slides[counter]);
$('#slide').fadeTo('fast', 1);
});
$('#slide-right').click(function() {
$('#slide').fadeTo('fast', 0);
$('#slide p').remove();
if (counter < (slides.length-1)){counter ++;}
$('#slide').append(slides[counter]);
$('#slide').fadeTo('fast', 1);
});
});