JS(二十四)遮盖层
来源:互联网 发布:浙江日报撤资淘宝天下 编辑:程序博客网 时间:2024/06/03 15:59
(function (a) { "use strict"; if ("function" === typeof define && define.amd) define(["jquery"], a); else if ("object" === typeof exports) module.exports = a(require("jquery")); else { if ("undefined" === typeof jQuery) throw "Dropdown requires jQuery to be loaded first"; a(jQuery); }})(function ($) { $.fn.cloak = function (text) { var divCloak = $('<div class="jq-cloak-main">' + '<div class="jq-cloak-content">' + (text ? text : 'Loading...') + '</div>' + '</div>'); $(this).prepend(divCloak); if ($(this).get(0).tagName !== 'BODY'){ divCloak.width($(this).outerWidth()); divCloak.height($(this).outerHeight()); divCloak.css('margin-left', '-' + $(this).css('padding-left')); divCloak.css('margin-top', '-' + $(this).css('padding-top')); } else{ divCloak.width('100%'); divCloak.height('100%'); } divCloak.find('.jq-cloak-content').css('margin-left', -divCloak.find('.jq-cloak-content').width() / 2); }; $.fn.uncloak = function () { $('div.jq-cloak-main').remove(); };});
添加和去掉遮盖:
$('body').cloak('<i class="fa fa-spinner fa-spin mr-10"></i>玩命加载中...');$('body').uncloak();
阅读全文