*jquery 的拓展方法
*/
/**
* 给btn 添加去除disabled
*/
$.fn.disabled = function() {
$(this).each(function(index,em){
var _this = $(em);
if(_this.is('button')||_this.is('input[type="button"]')){
_this.prop('disabled','disabled');
_this.css('cursor','not-allowed');
_this.removeClass('u-btnBlue');
_this.css({'background': '#1f5183','color': '#fff'});
}else if (_this.is('input')) {
_this.prop('disabled','disabled');
}else if (_this.is('.u-btn')) {
_this.addClass('u-btnDisable');
var _width = _this.outerWidth();
var _height = _this.outerHeight();
var _zIndex = _this.css("z-index");
console.log(parseFloat(_zIndex));
_this.css('position','relative');
var mark = $("<div class='mark'></div>").css({"z-index":_zIndex+1,"width":_width,"height":_height,"opacity":0.5,"top":0,"left":0,"position":"absolute","background-color":"transparent"});
_this.append(mark);
mark.click(function(){
return false;
});
};
});
};
Number.prototype.formatMoney = function(places, symbol, thousand, decimal) {
places = places || 0;
places = !isNaN( places = Math.abs(places)) ? places : 2;
symbol = symbol !== undefined ? symbol : "";
thousand = thousand || ",";
decimal = decimal || ".";
var number = this,negative = number < 0 ? "-" : "", i = parseInt( number = Math.abs(+number || 0).toFixed(places), 10) + "", j = ( j = i.length) > 3 ? j % 3 : 0;
number = symbol + negative + ( j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + ( places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
return number == 0?0:number;
};
/**
* 格式化后转number字符串
* @param {Object} symbol 货币标识
* @param {Object} thousand 分隔符
* @param {Object} decimal 小数点符号
*/
String.prototype.formatMoneyToNumber = function(symbol, thousand, decimal) {
var string = this;
string = string || '0';
symbol = symbol || "";
symbol = symbol !== undefined ? symbol : "";
thousand = thousand || ",";
decimal = decimal || ".";
return string.replace(symbol, '').replace(new RegExp(thousand,"g"), '').replace(decimal, '.');
};