我正在尝试找到正确的代码语法来放入"加载gif"加载功能可以将信息插入我的页面......
<script>
('#myinfo').load('/data/myinfo.html');
</script>
我是否必须将加载gif放入其中?
答案 0 :(得分:0)
Per https://www.w3schools.com/howto/howto_css_loader.asp,这是一个两步过程,没有JS:
1.在您想要微调器的位置添加此HTML:
2.添加此CSS以制作实际的微调器:
.loader {
border: 16px solid #f3f3f3; /* Light grey */
border-top: 16px solid #3498db; /* Blue */
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
答案 1 :(得分:0)
<script>
//delay script until after the page has been parsed into the DOM
$(document).ready(function(){
//get a reference to whatever holds the gif, or the gif itself
var $loadingGif = $(selectorForLoadingGif);
//show the gif before the load starts
$loadingGif.show();
//load the other info
$('#myinfo').load('/data/myinfo.html', function(){
//this method executes after the load finishes
//hide the loading gif
$loadingGif.hide();
});
});
</script>