我有 var a=99.90090 我想将其修复为仅 99 并将其显示在文本框中,但 var a 的原始值应保持不变。
我想要像我们在 iphone 中做的那样
SevereEIULabel.text=[NSString stringWithFormat:@"%.2f",appDelegate.Same_Vaccination_SevereEI_Unvaccinated];
我有 var a=99.90090 我想将其修复为仅 99 并将其显示在文本框中,但 var a 的原始值应保持不变。
我想要像我们在 iphone 中做的那样
SevereEIULabel.text=[NSString stringWithFormat:@"%.2f",appDelegate.Same_Vaccination_SevereEI_Unvaccinated];
a = 99.90090;
b = a.toFixed(0); // 100
b = a.toFixed(1); // 99.9
编辑
b = parseInt(99.90090); // 99
编辑 2
<input type="text" id="my_field" name="my_field" value="" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script>
a = 99.90090;
$('#my_field').val(parseInt(a));
</script>
为什么那么认真.............
<script type="text/javascript">
function fnc()
{
var value=99.90090;
testvalue=parseInt(value);
document.getElementById("atext").value=testvalue;
}
</script>
<input type="text" value="" id="atext" />
<input type="button" onclick="fnc()" value="click me" />
检查此代码,如果我对您要求实施的内容有误,请告诉我 -
var a=99.90090;
document.write(parseInt(a.toString()));
var a =99.90090;
temp = parseInt(a);
document.write(temp);
检查我的代码并提醒我是否需要任何更改