Reputation: 780
I need to change the eq(0)
and eq(6)
values to itemRow
and itemCol
values.
var itemRow = element.parentNode.parentNode.rowIndex;
var itemCol = element.parentNode.cellIndex;
$('#tblItem tbody tr:eq(0) td:eq(6)').text("0.00");
This is my current code but it's not working:
$('#tblItem tbody tr:eq(' + itemRow + ') td:eq(' + itemCol + 1 + ')').text("0.00");
Upvotes: 0
Views: 29
Reputation: 337560
You need to wrap itemCol + 1
in parentheses so it's processed before the concatenation:
$('#tblItem tbody tr:eq(' + itemRow + ') td:eq(' + (itemCol + 1) + ')').text("0.00");
var itemRow = 1; //element.parentNode.parentNode.rowIndex;
var itemCol = 0; //element.parentNode.cellIndex;
$('#tblItem tbody tr:eq(' + itemRow + ') td:eq(' + (itemCol + 1) + ')').text("0.00");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="tblItem">
<tbody>
<tr>
<td>a</td>
<td>b</td>
</tr>
<tr>
<td>c</td>
<td>d</td>
</tr>
</tbody>
</table>
Upvotes: 1