私は、行をループして特定のセルの値を取得する関数を持っています。それは成功し、私はそれらの個々の価値を返すことさえできます。しかし、複数回試しても何も返されません。ここに私のJSFiddle何も返さないセルの値を掛ける
はここにある私の関数である:あなたは、ロジックの問題がいくつかあり
$('#' + value + ' .totalRacks').each(function() {
$.each(this.cells, function() {
var index = $(this).index() + 1;
var prevRow0 = $(this).closest('tr').prev().find('td:nth-child(' + index + ')');
var prevRow1 = $(this).closest('tr').prev().prev().prev().find('td:nth-child(' + index + ')');
if (!isNaN(parseInt(prevRow0.text()))) {
var td1 = parseInt(prevRow0.text());
}
if (!isNaN(parseInt(prevRow1))) {
var td2 = parseInt(prevRow1);
}
var product = parseInt((td1 * td2));
$(this).html(product);
});
});
:これを試してみてください最初の 'if'のように' text() 'の値を取っていません。 'if'条件と同じです。 – trincot
葉巻はまだ追加されていません – sm1l3y