//显示加载动画
function show_loading(){
var str='<div class="msg_bg" style="background:#000;opacity:0.5;filter:alpha(opacity=50);z-index:99998;width:100%;position:absolute;left:0;top:0"></div>';
str+='<div class="msg_bg" style="z-index:99999;width:100%;position:absolute;left:0;top:0;text-align:center;"><img src="img/loading.gif" alt="" class="loading"></div>'
$('body').append(str);
var scroll_height=$(document).scrollTop();
$('.msg_bg').height($(document).height());
$('.loading').css('margin-top',scroll_height+240);
function show_loading(){
var str='<div class="msg_bg" style="background:#000;opacity:0.5;filter:alpha(opacity=50);z-index:99998;width:100%;position:absolute;left:0;top:0"></div>';
str+='<div class="msg_bg" style="z-index:99999;width:100%;position:absolute;left:0;top:0;text-align:center;"><img src="img/loading.gif" alt="" class="loading"></div>'
$('body').append(str);
var scroll_height=$(document).scrollTop();
$('.msg_bg').height($(document).height());
$('.loading').css('margin-top',scroll_height+240);
}
点击按钮后执行上述方法;
执行加载动画的JavaScript方法

本文介绍了一段JavaScript代码,用于在网页上显示加载动画。通过定义两个CSS类的div元素,实现背景颜色、透明度、宽度、位置等样式设置,并通过函数show_loading()将这些元素添加到页面body中,同时根据滚动高度调整动画元素的位置。
2276

被折叠的 条评论
为什么被折叠?



