如何检索td输入文本框值?

时间:2012-01-27 06:58:55

标签: javascript jquery

在下表中,在点击功能(removeRow)上,我想检索文本框的值(文本总金额)。

我写了这个

function removeRow(name) { 
  $(name).parent().parent().remove(); 
  var total = $(name).parent().parent().siblings().find("input .classTotalAmount").val();
  alert(total);// shows only undefined in alert box 
}

这是我的表

    <table id="tblitems" cellpadding="0" cellspacing="0" border="0" class="additemtb">
  <tbody>
      <tr>
          <th>Item Name</th>
          <th>Item Code</th>
          <th>Unit Price</th>
          <th>Qty</th>
          <th>UOM</th>
          <th>Amount</th>
          <th>Minimal Order Qty</th>
          <th>FOC</th>
          <th></th>
      </tr>
      <tr>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td style="width:90px;">
              <a href="javascript:void(0)" class="copy" onclick="copyRow(this);">Copy</a>
              <a href="javascript:void(0)" class="delete" onclick="removeRow(this);">delete</a>
              <a href="javascript:void(0)" class="add" onclick="addRows(this)">add</a>
          </td>
      </tr>
      <tr>
          <td></td>
          <td >Total Amount</td>
          <td>
              <asp:TextBox ID="txtTotalAmount" CssClass="classTotalAmount number" Columns="8" runat="server" ></asp:TextBox>
              <asp:Label ID="Label2" runat="server" CssClass="classCurrency3" />
          </td>
          <td>&nbsp;</td>
      </tr>
  </tbody>
</table>

1 个答案:

答案 0 :(得分:0)

var amount = $("#txtTotalAmount").val();