一、
function calculate(index) {
if (index != null) {currentStep = $(index).parent().parent().find("td:first-child").html();
}
if (currentStep == 0) {
alert('未能获得所在行焦点,无法自动计算!');
return false;
}
else {
currentStep =parseInt( currentStep)+ 1;
var tab = document.getElementById("content");
var price = tab.rows[currentStep].cells[4].innerHTML;
var $thisTD = $(index).parents("tr").find("td:eq(5)"); //此处需获取某td内 控件的值 使用childNote 在ie下可以 不兼容chrome 故改用 JQuery
var Quantity = $thisTD.find("input").val();
var total = (price * Quantity).toFixed(2);
alert(price);
alert(Quantity);
alert(total);
tab.rows[currentStep].cells[6].innerHTML = total;
}
}
二、Jquery的.html()方法可能会带有特殊符号,所以尽量避免使用,还是使用 input 更为保险。
如var ID = $(this).find("td:eq(0)").find("input").val();