javascript - JQuery 获取表中的选择元素

标签 javascript jquery html

我有以下表格元素,其 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");

http://api.jquery.com/class-selector/

关于javascript - JQuery 获取表中的选择元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19232697/

相关文章:

javascript - 在 Sencha Touch 中提交表单

javascript - 欺骗 Javascript.location.hostname

javascript - 无法删除 MarkerWithLabel

html - 如何在 bootstrap 5 中使用卡片制作完美的圆形图像?

javascript - react : render list Object directly from function inside <ul></ul> with an id?

javascript - 网站底部在 Chrome 中变白了

javascript - jquery 显示相同高度和宽度的图像

javascript - 最新的 Chrome 桌面更新阻止 SoundJS 播放声音(与自动播放相关)

javascript - 我可以在用户手机日历中以编程方式添加事件吗?

jquery - 用 jquery 去除所有 html 标签?