我正在使用accounting.js,我需要动态格式化值。
$('#<%=txtamount1.ClientID %>').bind('keydown keyup keypress focus blur paste change', function () {
result = accounting.formatMoney(
$('#<%=txtamount1.ClientID %>').val(),
'',
2,
","
);
$('#<%=txtamount.ClientID %>').val(result);
});
答案 0 :(得分:0)
$(document).ready(function () {
$('#txtamount1').live('keyup change', function (e) {
$(this).val(function () {
return accounting.formatMoney(($(this).val()+ String.fromCharCode(e.keyCode)), '', 2, ",");
});
});
$('#txtamount1').trigger('keyup');
});
直播演示,请参阅此链接:http://jsfiddle.net/nanoquantumtech/2s9wQ/