【发布时间】:2015-06-16 16:02:59
【问题描述】:
我想在表格价格文本框值发生变化时获取行索引和文本框值。目前我得到了一些未定义的值。
HTML
<table class="table table-striped">
<thead>
<tr>
<th>Product</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="text" class="form-control product">
</td>
<td>
<input type="text" oninput="javascript:GetValue(this);" class="form-control price">
</td>
</tr>
</tbody>
</table>
JavaScript
function GetValue(oTextBox) {
var price = oTextBox.value;
var product = oTextBox.parent().prev().innerHTML.value;
var rowindex = oTextBox.closest('tr').index();
}
我收到此错误:
TypeError: oTextBox.parent 不是函数 var product = oTextBox.parent().prev().innerHTML.value;
【问题讨论】:
标签: javascript jquery