我有以下表格元素,其 td 中有一个选择元素。表ID(示例中的table1)可以不断变化。那么,如何在 JQuery 中使用表 ID 获取所选选项呢?
<table class="indexViews" id = "table1">
<tr>
<td align="center", width="10%" valign="middle"></td>
<td align="center", width="70%" valign="middle">
<select id="indexViewsList" class="indexViewsListWnd" onChange="switchIndexView(this)">
<option id="0" value="0" selected="selected">Index Quick View</option>
<option id="1" value="1">Identifier View</option>
<option id="2" value="2">Commodity</option>
</select></td>
<td align="right", width="10%" valign="middle"><input class="searchIcon" type="image" src="../../images/downloadIcon.gif" alt="Submit" onClick="downloadIndexFile()"></input></td>
</tr>
</table>
最佳答案
我不明白为什么你的 id 不断变化。但也许您会想使用类名上的 jquery 选择器来迭代您的表。
var lstIndexView = $(".indexViews .indexViewsListWnd");
关于javascript - JQuery 获取表中的选择元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19232697/