Do mobile phone page We often encounter numbers, and in the Safari browser these numbers will display the phone number by default, so we use the method of pit to add <meta>
tags:
<meta name= "format-detection" content= "Telephone=no" >
The meaning of this tag is that the number is not treated as a phone number, so it's all right. O (∩_∩) O, but if it is a reservation phone, then after adding the label, the order number will become a digital, you can not dial directly so we think of the old number of thousands of characters to distinguish between telephone numbers and numbers
thousand characters
In the west, when representing a large number, will be separated by every 3 bits of the interval, the symbol is a comma, because in Chinese, the 3rd place is "thousand", therefore, the number of the "comma" is also known as the "thousands separator."
The reason for this is that each of the 3-bit separators is related to readings in English, for example: the 987,654,321 reading of English is: nine hundred and eighty-seven billion six hundred and Fifty-four thousand three hundred and twenty-one.
Its key unit of values, such as billion
, thousand
is exactly where the thousand separators are. It can be seen that this separation is complementary to Western numerical reading methods.
But for Chinese users, this style is rather awkward. Our large value units are mainly "million" and "billion", if the division according to this standard, should be every 4 bits to separate. So, when we first saw the 3-bit numbers, it would be strange that the way they were separated was somewhat out of order.
Is there a solution to that?
Method One:
Method One: Use regular expressions
The syntax is as follows:
String (number). Replace (/(\d) (? = (\d{3}) +$)/g, "$");
Example:
String (123456789). Replace (/(\d) (? = (\d{3}) +$)/g, "$");
Method Two:
Method Two: Use
toLocaleString()
Method
The syntax is as follows:
Number.tolocalestring (' en-us ');
Example:
(123456789). toLocaleString (' en-us ');
The result is: 123,456,789
In the Chinese scene, toLocaleString(‘en-US‘)
in ‘en-US‘
theory can be the default, that is, directly (123456789).toLocaleString()
can also get 123,456,789. However, if your product may be used by overseas users, it is safe to keep it ‘en-US‘
.
In addition, for the previous version of IE Edge, Number.toLocaleString()
will automatically fill up two decimal places, if it is not needed, you need to filter out the extra.
Use a thousands separator (comma) to represent large numbers in a Web page