jq 插件化巨坑 loading 拷贝副本替换法

点哪个哪个显示加载

js

//调用
$(even).mini_load();//显示加载
$(even).mini_loaded();//回到原来的样子


$.fn.extend({
    mini_load:function(msg,color){
        var msg=(typeof(msg)=="undefined")?"操作中...":msg;
        var that=$(this);
        var that_copy=$(that).clone();
        var color=(typeof(color)=="undefined")?"white":"black";
        var img_load=document.createElement("span")
        img_load.className="span_loading";
        that_copy.attr("copy","loadingcopy");
        that_copy.html(msg);
        that_copy.prepend(img_load);
        $(that_copy).removeAttr("onclick");
        that.hide();
        that.after(that_copy);
    },
    mini_loaded:function(){
        var that=$(this);
        that.show();
        that.siblings("[copy='loadingcopy']").remove();
    }
})

css

.span_loading{
  background: url(../images/loading-white.gif);
  width:20px;
  height: 20px;
  display: inline-block;
  background-size: 100%;
  vertical-align:middle;
}