<tr class="item-row" id="itemsRow">
<td></td>
<td><input class="tInput" id="invoiceNo" readonly/> </td>
<td><input class="tInput" id="clientId" readonly /> </td>
<td><input class="tInput" id="issueDate" readonly/></td>
<td><inpu class="tInput" id="netTotal" readonly /> </td>
<td><input class="tInput" id="amountDue" readonly /> </td>
<td><input class="tInput" id="status" readonly /> </td>
</tr>
Im trying to get value of ‘input id=invoiceNo’ when I click to ‘input id=status’ using following code
var invno = $(this).closest('tr td:nth-child(2) input').val();
alert(invno);
It alerts ‘undefined’
so how to solve this?
closestdoes only search in theparent()array.So you have to search in your parent element: