Home > Web Front-end > JS Tutorial > How to write several decimal places using js_javascript skills

How to write several decimal places using js_javascript skills

WBOY
Release: 2016-05-16 17:15:11
Original
1215 people have browsed it

If the value of ${showInfo.tt} is 20, and you want it to be divided by 10 and be accurate to 2 decimal places, then the js code can be written as follows:

Copy the code The code is as follows:

var a = ${showInfo.tt}/10;
//alert(a.toFixed(3)); //The value obtained to 3 decimal places is 2.000
document.write(a.toFixed(2)); //The value obtained is 2.00
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template