且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何对两个输入字段求和

更新时间:2023-10-06 14:22:22

,您需要先分析这些文本框的值,然后再添加它们.您还需要修改输入元素选择器. ta是元素的ID.您应该使用id选择器(#):

you need to parse those textboxes values before adding them. you will also need to modify the input element selector. ta is id of element. you should use id selector(#):

$("#ta").keyup(function(){
var vat = parseInt($(this).val());
var total = parseInt($("#tp").val());
    total = vat+total;
$("#tp").val(total);
});