求个jquery封装,加载动画始终居中显示,代码已有,不会封装 本帖最后由 mafeifan 于 2013-06-07 12:23:55 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $.fn.extend({ shows: function() { var wnd = $(window), doc = $(document); var left = doc.scrollLeft(); var top = doc.scrollTop(); left += (wnd.width() - $('#indicator').width())/2; top += (wnd.height() - $('#indicator').height())/2; $(this).css("position","absolute"); $(this).css("top",top); $(this).css("left",left); $(this).show(); return this; }});调用:$('#indicator').shows(); $.fn.extend({ shows: function() { var wnd = $(window), doc = $(document); var left = doc.scrollLeft(); var top = doc.scrollTop(); left += (wnd.width() - $('#indicator').width())/2; top += (wnd.height() - $('#indicator').height())/2; $(this).css("position","absolute"); $(this).css("top",top); $(this).css("left",left); $(this).show(); return this; }, hides: function() { var wnd = $(window), doc = $(document); var left = doc.scrollLeft(); var top = doc.scrollTop(); left += (wnd.width() - $('#indicator').width())/2; top += (wnd.height() - $('#indicator').height())/2; $(this).css("position","absolute"); $(this).css("top",top); $(this).css("left",left); $(this).hide(); return this; }}); 调用:$('#indicator').shows().hides(); $.fn.extend({ shows: function() { var wnd = $(window), doc = $(document); var left = doc.scrollLeft(); var top = doc.scrollTop(); left += (wnd.width() - $(this).width())/2; top += (wnd.height() - $(this).height())/2; $(this).css("position","absolute"); $(this).css("top",top); $(this).css("left",left); $(this).show(); return this; }, hides: function() { var wnd = $(window), doc = $(document); var left = doc.scrollLeft(); var top = doc.scrollTop(); left += (wnd.width() - $(this).width())/2; top += (wnd.height() - $(this).height())/2; $(this).css("position","absolute"); $(this).css("top",top); $(this).css("left",left); $(this).hide(); return this; }}); 调用:$('#indicator').shows().hides();这个正确 请问$.fn.extend({}); 这段代码放在什么位置 单一个js文件也行,放head里也行调用加个$(function() {}); javascript如何取数组中时间计算,算出分钟 javascript 高手进,关于正则表达式 为什么ocx事件没响应啊? 图片"分页滚动",来着有分,将奉送2008-1-1号之前所有赚到的分数 怎样用正则表达式从一个字符串中获取特定值 判断图片是否读取完成 谁有“Document Object Model”资料?高分酬谢! 如果Form上有50個checkbox,如何用一條語句判斷出checkbox的狀態全為false? 如何在点击文件链接后均弹出文件下载框 求助大神,无法访问此网站 localhost 拒绝了我们的连接请求 js打印 研究过淘宝API的请进
shows: function() {
var wnd = $(window), doc = $(document);
var left = doc.scrollLeft();
var top = doc.scrollTop(); left += (wnd.width() - $('#indicator').width())/2;
top += (wnd.height() - $('#indicator').height())/2;
$(this).css("position","absolute");
$(this).css("top",top);
$(this).css("left",left);
$(this).show(); return this;
}
});调用:
$('#indicator').shows();
shows: function() {
var wnd = $(window), doc = $(document);
var left = doc.scrollLeft();
var top = doc.scrollTop();
left += (wnd.width() - $('#indicator').width())/2;
top += (wnd.height() - $('#indicator').height())/2;
$(this).css("position","absolute");
$(this).css("top",top);
$(this).css("left",left);
$(this).show();
return this;
},
hides: function() {
var wnd = $(window), doc = $(document);
var left = doc.scrollLeft();
var top = doc.scrollTop();
left += (wnd.width() - $('#indicator').width())/2;
top += (wnd.height() - $('#indicator').height())/2;
$(this).css("position","absolute");
$(this).css("top",top);
$(this).css("left",left);
$(this).hide();
return this;
}
});
调用:
$('#indicator').shows().hides();
shows: function() {
var wnd = $(window), doc = $(document);
var left = doc.scrollLeft();
var top = doc.scrollTop();
left += (wnd.width() - $(this).width())/2;
top += (wnd.height() - $(this).height())/2;
$(this).css("position","absolute");
$(this).css("top",top);
$(this).css("left",left);
$(this).show();
return this;
},
hides: function() {
var wnd = $(window), doc = $(document);
var left = doc.scrollLeft();
var top = doc.scrollTop();
left += (wnd.width() - $(this).width())/2;
top += (wnd.height() - $(this).height())/2;
$(this).css("position","absolute");
$(this).css("top",top);
$(this).css("left",left);
$(this).hide();
return this;
}
});
调用:
$('#indicator').shows().hides();这个正确