如何添加淡入效果?

发布于 2024-10-05 06:14:45 字数 381 浏览 1 评论 0原文

我该如何添加淡入效果?

  $(document).ready(function(){
  var myQuotes = new Array(); 
  myQuotes[0] = "All is connected... "; 
  myQuotes[1] = "The best way"; 
  myQuotes[2] = "Your work is to discover"; 
  myQuotes[2] = "If success";

  var myRandom = Math.floor(Math.random()*myQuotes.length); 
  $('#quoteHome').html(myQuotes[myRandom]);      

});

How would I add a fade in to this?

  $(document).ready(function(){
  var myQuotes = new Array(); 
  myQuotes[0] = "All is connected... "; 
  myQuotes[1] = "The best way"; 
  myQuotes[2] = "Your work is to discover"; 
  myQuotes[2] = "If success";

  var myRandom = Math.floor(Math.random()*myQuotes.length); 
  $('#quoteHome').html(myQuotes[myRandom]);      

});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

挽清梦 2024-10-12 06:14:45

您可以将 .hide().fadeIn(),如下所示:

$('#quoteHome').html(myQuotes[myRandom]).hide().fadeIn();

You can just chain a .hide() with a .fadeIn(), like this:

$('#quoteHome').html(myQuotes[myRandom]).hide().fadeIn();
渔村楼浪 2024-10-12 06:14:45

使用这个方法:

$('#quoteHome').hide().html(myQuotes[myRandom]).fadeIn('fast');

Use this method:

$('#quoteHome').hide().html(myQuotes[myRandom]).fadeIn('fast');
爱*していゐ 2024-10-12 06:14:45
 $('#quoteHome').fadeIn();

 $('#quoteHome').fadeIn(1000); //duration in milliseconds

 $('#quoteHome').fadeIn('fast'); //speed
 $('#quoteHome').fadeIn();

 $('#quoteHome').fadeIn(1000); //duration in milliseconds

 $('#quoteHome').fadeIn('fast'); //speed
一口甜 2024-10-12 06:14:45

再简单不过了。

$('#quoteHome').html(myQuotes[myRandom]).fadeIn('slow');

只需确保从一开始就将 #quoteHome 设置为 display:none

couldn't be easier.

$('#quoteHome').html(myQuotes[myRandom]).fadeIn('slow');

Just make sure that #quoteHome is set to display:none from the getgo.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文