这是我尝试使用的代码:
<div class"text><p>life is the best gift of nature</p>
<p>will were born to be the best</p>
然后在我的app.js文件中的jQuery中:
$('.text').fadeOut(5000).addClass('.text').fadeIn(5000);
答案 0 :(得分:1)
你是说这个?
JS:
$('.text').fadeOut(5000, function(){
$('.text').text("will were born to be the best").fadeIn(5000);
})
fadeOut()
中还有另一个函数参数,因为它是一个“回调”函数。只有在淡入淡出完成后才会执行。
HTML:
<p class="text">life is the best gift of nature</p>
$(function(){
$('.text').fadeOut(5000, function(){
$('.text').text("will were born to be the best").fadeIn(5000);
})
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<p class="text">life is the best gift of nature</p>