Home>

Examples are as follows:

/**
 * Number format conversion to thousands
 *@param {object} num
 * /
function commafy (num) {
  if ((num + ""). trim () == "") {
   return "";
  }
  if (isnan (num)) {
   return "";
  }
  num=num + "";
  if (/^.*\..*$/. test (num)) {
   varpointindex=num.lastindexof (".");
   varintpart=num.substring (0, pointindex);
   varpointpart=num.substring (pointindex + 1, num.length);
   intpart=intpart + "";
    var re =/(-?\ d +) (\ d {3}) /
    while (re.test (intpart)) {
     intpart=intpart.replace (re, "$1, $2")
    }
   num=intpart + "." + pointpart;
  } else {
   num=num + "";
    var re =/(-?\ d +) (\ d {3}) /
    while (re.test (num)) {
     num=num.replace (re, "$1, $2")
    }
  }
  return num;
}
/**
 * Remove thousands
 *@param {object} num
 * /
function delcommafy (num) {
  if ((num + ""). trim () == "") {
   return "";
  }
  num=num.replace (/,/gi, "");
  returnnum;
}
  • Previous JQuery proxy to implement the proxy method
  • Next jQuery simply implements iframe height adaptive method based on page content