HTML jQuery 加载数据转圈提示代码 - 快速实现数据加载状态展示
以下是一个示例代码,用于在加载数据时显示转圈提示。
HTML:
<div id='loading' style='display: none;'>
<div class='spinner'></div>
</div>
CSS:
.spinner {
width: 40px;
height: 40px;
position: relative;
margin: 100px auto;
}
.spinner:before {
content: '';
display: block;
width: 25px;
height: 25px;
border-radius: 50%;
border: 3px solid #ccc;
border-top-color: #333;
position: absolute;
top: 50%;
left: 50%;
margin-top: -12.5px;
margin-left: -12.5px;
animation: spin .6s linear infinite;
}
@keyframes spin {
100% { transform: rotate(360deg); }
}
jQuery:
$(document).ajaxStart(function() {
$('#loading').show();
});
$(document).ajaxStop(function() {
$('#loading').hide();
});
此代码在页面上创建了一个隐藏的转圈提示,并使用jQuery的ajaxStart和ajaxStop事件来显示和隐藏转圈提示。
原文地址: https://www.cveoy.top/t/topic/lHWe 著作权归作者所有。请勿转载和采集!