input标签下两位小数金额及靠右显示

1、输入标签

<input type="number" class="form-control dec2" id="amt" name="amt">

2、靠右显示css

input[type="number"]{
    -moz-appearance: textfield;
    text-align : right;
}

3、失去焦点后显示两位小数点js脚本

<script>
    $(function(){
        $('input.dec2').blur(
            function(){
                $(this).val(parseFloat($(this).val()).toFixed(2));
            }
        ); 
    });
</script>
posted @ 2020-01-02 16:09  鸿翔软件小屋  阅读(589)  评论(0)    收藏  举报