[英]How to get drop down list value per selected row?
我有一張桌子,看起來像這樣
<table id="grid" class="table table-bordered table-hover table-inline">
<thead>
<tr>
<th>Id</th>
<th>Dropdown List</th>
<th><input id="selectAll" type="checkbox" /></th>
</tr>
</thead>
<tbody data-bind="foreach: stuff
<tr>
<td data-bind="text: someId"></td>
<td>
<select class="input-medium" data-bind="options: someStuff, optionsText:'DisplayName', optionsValue:'StandardCode'"></select>
</td>
<td>
<input type="checkbox" data-bind="value: someId"/>
</td>
</tr>
</tbody>
</table>
然后我的JavaScript我正在遍歷這樣的選定行
$('grid input[type="checkbox"]:checked').each(function () {
var someSelectedId= $(this).val();
var dropDownlistValue= ??
});
我正在使用淘汰賽將數據綁定到表和下拉列表。
當我遍歷各行時,如何遍歷各行?如何在下拉列表中為每一行獲取選定的值? 對於我的一生,我似乎無法弄清楚。 謝謝!
采用:
var dropDownlistValue = $(this).parent().prev().find('select.input-medium').val();
要么...
$(this).closest("tr").find("select.input-medium").val();
AV的方法可能更快,但是轉到TR可以提供更大的靈活性,因為無論行在何處,它都能找到選擇內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.