效果图如下

每行的小计是通过订购数量*单价算出来 通过jquery动态改变的
开始吧 在html中触发
商品名称:
序号
商品
规格
单位
可售库存
订购数量
单价
小计
备注
操作
删除
合计
js如下
//行内金额小计
function subProductPrice(obj) {
var total = 0;
if ($(obj).val() != '' && $(obj).val() != null && $(obj).val() != undefined) {
total += parseInt($(obj).val()) * parseInt($(obj).parents('tr').find('.productPrice').val());
}
$(obj).parents('tr').find("[data-name='subProductPrice']").val(total);
}
function subGiftPrice(obj) {
var total = 0;
if ($(obj).val() != '' && $(obj).val() != null && $(obj).val() != undefined) {
total += parseInt($(obj).val()) * parseInt($(obj).closest(".giftPrice").val());
}
$(obj).find("[data-name='giftPriceTotal']").text("¥" + total)
}
//金额总计
function totalProductPrice(obj) {
var total=0;
// console.log( $('#tblproduct .subProductPrice').val())
$('#tblproduct .subProductPrice').each(function () {
if($(this).val() != '' && $(this).val() != null && $(this).val() != undefined) {
total += parseInt($(this).val())
}
})
$("[data-name='totalProductPrice']").text('¥'+total)
}
function totalGiftPrice(obj) {
var total=0;
$('#tblgift .subGiftPrice').each(function () {
if($(obj).text() != '' && $(obj).text() != null && $(obj).text() != undefined) {
total += parseInt($(obj).text())
}
})
$("[data-name='totalGiftPrice']").text('¥'+total)
}
由于是js改变的value所以onchange不好用了 onproperty又只支持ie onpinput也不行
请问怎么办 才能监听到小计的变化从而改变总金额
求大神指点
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
归根结底还是由用户的点击行为触发的,你可以给可能改变总计的鼠标事件都调用一个重算总价的方法。