最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - show a div after loading another div - Stack Overflow

programmeradmin1浏览0评论

I have two div

E.g.

<div class="first">
   //Div first content
</div>

<div class="second">
   //Div second contents
</div>

Initially div second is hidden . I want to show div "second" after loading div "first" with a delay.

I triend $('first').load() in jquery ,but it is not working. I am pletely new to jquery,how to do it in an efficient way

I have two div

E.g.

<div class="first">
   //Div first content
</div>

<div class="second">
   //Div second contents
</div>

Initially div second is hidden . I want to show div "second" after loading div "first" with a delay.

I triend $('first').load() in jquery ,but it is not working. I am pletely new to jquery,how to do it in an efficient way

Share Improve this question edited Nov 14, 2015 at 16:26 Andreas 21.9k7 gold badges51 silver badges58 bronze badges asked Nov 14, 2015 at 16:20 It AssistorsIt Assistors 1,1283 gold badges16 silver badges30 bronze badges 3
  • where is your scripts which tried so far – Azad Commented Nov 14, 2015 at 16:28
  • Do you need to show the second after a while, or showing second after the first one is actually loaded? – holden Commented Nov 14, 2015 at 16:36
  • Not sure if it was just a typo in when copying it over, but you're missing the period in your class selector. You wrote $('first').load() but it should be $('.first').load() – catch22 Commented Nov 15, 2015 at 17:13
Add a ment  | 

2 Answers 2

Reset to default 5

try this

$(document).ready(function() {
$(".second").delay(2000).fadeIn(500);
});

You can wait for the first div to load before loading the second using either the .ready or .load methods provided by jQuery. Here's a fiddle to see it in action.

.second {
  display: none;
}


$('.first').ready(function() {
  setTimeout(function() {
    $('.second').css("display", "block");
  }, 500);
});
发布评论

评论列表(0)

  1. 暂无评论