$("#mytable").on("change", "select", function() {
var getSelectValue = $(this).val();
if (getSelectValue == 1) {
$(this).parents('td').next().find('#fee-2').prop('disabled', true);
$(this).parents('td').next().next().find('#fee-1').prop('disabled', false);
} else {
$(this).parents('td').next().find('#fee-2').prop('disabled', false);
$(this).parents('td').next().next().find('#fee-1').prop('disabled', true);
}
});
JSFIDDLE
更新时间:增加的两个类文本框.i.e fee_course_1,fee_course_2
,所以我们可以遍历,并得到和值
$("#calsum").click(function() {
var sum_fee_1 = 0;
var sum_fee_2 = 0;
$('.fee_course_1').each(function() {
sum_fee_1 += Number($(this).val());
});
$('.fee_course_2').each(function() {
sum_fee_2 += Number($(this).val());
});
alert("Fee_1 = " + sum_fee_1 + " and Fee_2 = " + sum_fee_2);
});
JS FIDDLE DEMO 2
惊人的,谢谢!但是请分别用费用1和费用2计算所有领域的总和。 – Ada
@GreatGhazal:您好 –