HTML5号码输入 - 始终显示2位小数 [英] HTML5 Number Input - Always show 2 decimal places

查看:960
本文介绍了HTML5号码输入 - 始终显示2位小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

格式化输入[type ='number'] 的值是否有任何方法总是显示2位小数?



示例:我希望看到0.00而不是 0



谢谢
解决方案

解决了以下建议并添加了一段jQuery来强制整数格式 parseFloat($(this).val())。toFixed(2)


Is there's any way to format an input[type='number'] value to always show 2 decimal places?

Example: I want to see "0.00" instead of 0.

Thanks

解决方案

Solved following the suggestions and adding a piece of jQuery to force the format on integers parseFloat($(this).val()).toFixed(2)

这篇关于HTML5号码输入 - 始终显示2位小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆