[英]How to convert a decimal number into percentage using Javascript
I am trying to convert some decimal numbers present in the XML document into percentages using JavaScript but the code seems to be not working. 我正在尝试使用JavaScript将XML文档中存在的一些十进制数字转换为百分比,但是代码似乎无法正常工作。 Here is the html text : 这是html文本:
fols is <num> .595498</num><br/>
wif isa <num>.0656</num><br/>
dewi is <num>.6949</num><br/>
Now here is the JavaScript I used : 现在这是我使用的JavaScript:
function changeNumbers(){
for(i=1; i<= document.getElementByTagName("num").length; i++){
if(1<document.getElementByTagName("num").value<0){
UNum = document.getElementByTagName("num").value;
UNum = Math.round(UNum*100) + '%';
return UNum;
}
}
};
document.getElementByTagName("num").innerHTML = changeNumbers();
Can someone please push me in the right direction with the above JavaScript code. 有人可以通过上述JavaScript代码将我推向正确的方向吗? Thanks in advance !! 提前致谢 !!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.