It is necessary from the type of price 96 million rubles . get an auditory readable view, that is:


96 000 000 — 96 млн. 960 00 00 — 9,6 млн 96 000 — 96 000 9 600 — 9 600 960 — 960 

To solve this problem, I took the tools AbbrNum jQuery plugin

But I can’t remove ths, I want to leave only a million ,

 96 000 000 — 96 млн. 9 600 000 — 9,6 млн. 96 000 — 96 тыс. <=== нужно чтоб было так: 96 000 **без префикса тыс**. 9600 — 9 600 960 — 960 

How to do with spaces and remove a thousand ?

DEMO JSFIDDLE

Thank you for your attention.

  • Remove the class from tsiferok that do not want to handle plug-in - Oleksandr
  • remove class is not an option look at JSFIDDLE - Karen

1 answer 1

plug-in convert function, change in first 4 lines

 (function($) { $.fn.abbrNum = function(options) { var defaultVal = { decPlaces: 0 }; var options = $.extend(defaultVal, options); var convert = function(number, decPlaces) { var temp = number; number = number.replace(/\s+/g, ""); decPlaces = Math.pow(10, decPlaces); if (number.length < 7) return temp; // Enumerate number abbreviations var abbrev = [" тыс", " млн", " млрд", " трлн"]; // Go through the array backwards, so we do the largest first for (var i = abbrev.length - 1; i >= 0; i--) { // Convert array index to "1000", "1000000", etc var size = Math.pow(10, (i + 1) * 3); // If the number is bigger or equal do the abbreviation if (size <= number) { // Here, we multiply by decPlaces, round, and then divide by decPlaces. // This gives us nice rounding to a particular decimal place. number = Math.round(number * decPlaces / size) / decPlaces; // Handle special case where we round up to the next abbreviation if ((number == 1000) && (i < abbrev.length - 1)) { number = 1; i++; } // Add the letter for the abbreviation number += abbrev[i]; // We are done... stop break; } } return number; } this.each(function() { var element = $(this).prop('tagName').toLowerCase(); var decPlaces = options.decPlaces; if ($(this).attr('decplaces')) { decPlaces = $(this).attr('decplaces'); } if (element == 'div' || element == 'span') { var number = $(this).html(); number = convert(number, decPlaces); $(this).html(number); } else if (element == 'label') { var number = $(this).text(); number = convert(number, decPlaces); $(this).text(number); } else if (element == 'input') { var number = $(this).val(); number = convert(number, decPlaces); $(this).val(number); } }); } }(jQuery)); $(document).ready(function() { // no decimal places (default) $('.abbr-number').abbrNum(); // decimal places as attribute $('.abbr-number-attr').abbrNum(); // decimal places as option $('.abbr-number-opt').abbrNum({ decPlaces: 2 }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <!-- no decimal places (default) --> <label class="abbr-number">96 000 000</label> <br> <!-- decimal places as attribute --> <label class="abbr-number" decplaces="1">9 600000</label> <br> <!-- decimal places as option --> <label class="abbr-number" decplaces="1">96 000</label> <br> <!-- no decimal places (default) --> <label class="abbr-number" decplaces="1">9 600</label> <br> <!-- no decimal places (default) --> <label class="abbr-number">960</label> <br>