Home > Web Front-end > HTML Tutorial > javascript如何将10(分)转换为0.10(元)?_html/css_WEB-ITnose

javascript如何将10(分)转换为0.10(元)?_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:42:36
Original
1814 people have browsed it

JavaScript

RT,
javascript如何将10(分)转换为0.10(元)?

100(分)转换为1.00(元)?
请问这样的转换用javascript怎么实现?

回复讨论(解决方案)

http://www.codefans.net/jscss/code/3356.shtml
看一下这个

http://www.iteye.com/topic/1012779
这个也可以

function change(fen){
var yuan=fen/100.0;
return yuan.toFixed(2);
}

function change(fen){
var yuan=fen/100.0;
return yuan.toFixed(2);
}

toFixed不是通用的吧?

引用 3 楼 lengyuan8023 的回复:function change(fen){
var yuan=fen/100.0;
return yuan.toFixed(2);
}

toFixed不是通用的吧?

toFixed是javascript的方法,用于四舍五入,只要你用js编写,就可以用的

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