【问题标题】:Javascript function to load a DIV after the entire page is loaded [duplicate]加载整个页面后加载DIV的Javascript函数[重复]
【发布时间】:2016-01-03 23:17:51
【问题描述】:

我只想在加载整个页面后加载 DIV“图像”。

我需要什么 JS 代码?

<div class="row">
  <div class="image">
    CONTENT
  </div>
</div>

我将调用函数:

$(document).ready(function()

【问题讨论】:

  • 您可以在此处进行ajax调用并设置图像类div内容。

标签: javascript html load loaded


【解决方案1】:

只需将请求调用放在ready 函数中即可:

$(document).ready(function(){ //after the entire page is loaded.
   // load the DIV "image"
   $.get('url', function(data) {
        $('.image').html(data);
   });
});

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    $(window).load(function() {
      $('.image').fadeIn();
    });
    <div class="row">
      
        <!-- This will appear after image has been loaded -->
        <div class="image" style="display: none">
            CONTENT
        </div>
      
    </div>
    
    <img src="http://www.planwallpaper.com/static/images/colorful-triangles-background_yB0qTG6.jpg">
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

    【讨论】:

    • 是我瞎了,还是你的代码不起作用?无论如何,请评论您的代码..
    猜你喜欢
    • 2014-02-28
    • 2013-10-28
    • 2013-09-18
    • 2016-04-19
    • 1970-01-01
    • 2014-03-21
    • 1970-01-01
    • 2014-11-10
    • 1970-01-01
    相关资源
    最近更新 更多