我正在使用淘汰赛 JS。而在下拉的订阅功能中。我需要获取所选下拉列表的索引。
其中下拉列表在表内(即foreach tr)
HTML:
<table>
<tbody data-bind="foreach: Rows">
<tr>
<td>
<select data-bind="options: Materials, value: selectedMaterial,attr:{index:$(index)}"></select>
</td>
</tr>
</table>
脚本:
this.selectedMaterial.subscribe(function(data){
// I need to get the index value of the selectedMaterial
// i try to get like following code but its not working
var k =$(this).attr("index");
});