jquery - jQuery .load 在加载 html 内容之前等待动画
问题描述
我正在尝试用于.load
加载新的 html 页面,但我想在新的 html 加载之前淡入覆盖当前内容的全宽全高div
。使用我当前的代码,加载是瞬时的(不等待白色 div 淡入)。如何让加载功能等待动画完成?
对不起,如果这令人困惑,我想要的总结:
- 用户点击按钮
- 一个白色背景的大 div 淡入并覆盖所有内容
- 步骤 2 完成后,.load 加载新的 html。
我的代码:
$(".viewreport").click(function(){
$(".coverall").show().addClass("text-focus-in");
$(".coverall").promise().done(function(){
$("html").load( "report.html" );
});
});
解决方案
这个简单的解决方案是在超时设置为淡入所用的时间后调用负载。像这样的东西。
$(".viewreport").click(function(){
$(".coverall").show().addClass("text-focus-in");
$(".coverall").promise().done(function(){
setTimeout(function(){
$("html").load( "report.html" );
}, 3000);
});
});
推荐阅读
- python - 从 STEP 文件中提取参数方程
- ios - 安装 GraphQL iOS 框架
- javascript - Colspan 以匹配上方根据屏幕尺寸隐藏 td 的行
- javascript - 使用回调时从函数中获取空数组
- c - 为什么在 x64dbg 中加载 .exe 文件时找不到“_main”符号?
- android - 无法查看在 android studio 的设计视图中删除的文本视图
- java - 使用比较器,如何确定对象之间的匹配质量,或者有更好的方法
- javascript - 如何在 Angular 4 中的表单中按下按钮时将表单状态更改为脏状态?
- authentication - oAuth2 SSO 没有 Cookie
- javascript - Angular 6主题订阅不起作用