// 把生成命名空间的方法绑定在jQuery上 jQuery.namespace = function () { var a = arguments, o = null, i, j, d; for (i = 0; i < a.length; i = i + 1) { d = a[i].split("."); o = jQuery; for (j = (d[0] == "jQuery") ? 1 : 0; j < d.length; j = j + 1) { o[d[j]] = o[d[j]] || {}; o = o[d[j]]; } } return o; }; jQuery.namespace('jQuery.UnionMedical.Tools'); //格式化金额 jQuery.UnionMedical.Tools.FormatMoney = function (v) { v = (Math.round((v - 0) * 100)) / 100; v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v); v = String(v); var ps = v.split('.'); var whole = ps[0]; var sub = ps[1] ? '.' + ps[1] : '.00'; var r = /(d+)(d{3})/; while (r.test(whole)) { whole = whole.replace(r, '$1' + ',' + '$2'); } v = whole + sub; if (v.charAt(0) == '-') { return '-' + v.substr(1); } return v; };