jQuery load() 在 div 中显示 css 预加载器

标签 jquery html css

我使用一个按钮从另一个源加载内容,在 div 中使用此

$('button').click({ 
  $('somediv').load('source.php');
});

现在我想显示一个预加载器 div,其中包含 css 加载器;当我按下按钮时应该显示,直到 source.php 中的所有内容都加载到 div 中。谁能帮帮我???

最佳答案

使用load()的回调:

$('button').click({ 
    // show a loading div or something before start
    $(".loading").show();

    $('somediv').load('source.php', function() {
        // this will be executed once 'script.php' was loaded
        // hide the loading
        $(".loading").hide();
    });
});

关于jQuery load() 在 div 中显示 css 预加载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37985217/

相关文章:

javascript - 在行中对按其他列 ID 分组的一些其他列行值求和

javascript - 菜单没有像应该的那样向左滑动

html - 服务器端的正确文件类型是什么?

HTML5 CSS3 页脚栏

javascript - HTML 按钮重定向页面

jquery - 如何使用 CSS 类使 jQuery 幻灯片打开和关闭

python - Django render_to_string <body><head> 标签

html - 如何处理 Rails 表单文本区域中的恶意大输入

html - 使用 bootstrap 在移动设备上查看网站时,我的网站需要 flash 更改为静态图像吗?

javascript - Nivo slider 调整主图像的高度