javascript - 使用 jquery 查找数据表的表格单元格的内部值

标签 javascript jquery datatable cell html-table

我定义了以下数据表。

问题 - 绘制数据表后,当我从 slider jquery 输入检索值时,我收到跨度和整个文本而不是值。如何仅检索 sliderinput 的值?

 <table class="zebra" cellpadding ="0" cellspacing="0" border="0" id="subscriptionsTable" width="100%">
    <thead>
        <tr>
            <th>
                User  
            </th>
            <th>
                Name Full
            </th>
            <th>
                Sub Frequency
            </th>
            <th>
                Price
            </th>
            <th>
                Rep
            </th>
            <th>
                Sales
            </th>
            <th>
                Points
            </th>
            <th>
                Save
            </th>
        </tr>
    </thead>
    <tbody>
    </tbody>
</table>

以下是屏幕上的值,

    <td class="sorting_1">60728</td>
    <td>Les</td>
    <td>Y</td>
    <td>799</td>
    <td></td>
    <td></td>
    <td>
    <span class="ui-spinner ui-widget ui-widget-content ui-corner-all">
    <input id="pointSlider" class="ui-spinner-input" type="number" step="1" min="0" aria-valuemin="0" autocomplete="off" role="spinbutton" style="border-width: 1px; border-color: rgb(206, 206, 206);" aria-valuenow="4">
    <a class="ui-spinner-button ui-spinner-up ui-corner-tr ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button" aria-disabled="false">
    <a class="ui-spinner-button ui-spinner-down ui-corner-br ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button" aria-disabled="false">
    </span>
    </td>
td>
<img class="save" width="20px" title="Save this record" src="https://localhost:8443/project/images/Green_Check.png">
</td>

当我选择任何行时,我可以使用以下 jQuery 选择捕获行元素。

$(this).closest('tr').find('td').eq(0).html();

如何选择第 6 个元素?我有一个 ID=pointSlider 的 slider jquery,但找不到该值。

感谢您的帮助,jQuery 新手。

最佳答案

此选择有效。输入环绕在表格单元格中包含的范围内。 $(this).closest('tr').find('#pointSlider').val();

关于javascript - 使用 jquery 查找数据表的表格单元格的内部值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25191737/

相关文章:

javascript - 如何检测生成元素的点击?

javascript - 适合 map 以始终显示世界

javascript - 如何使用 Angular 在 typescript 中使用动态键访问JSON对象值

javascript - 如何修复 Three.js Cube 细线框?

jquery - 对于 >1000px 的值,向左动画图像不起作用

javascript - 获取一个数据表的值到另一个数据表

javascript - Moment() 与预定义的 Moment() 日期

Jquery mobile 点击元素将其删除

c# - 将 DataTable 转换为 LINQ 匿名类型

javascript - 当列数据也是数组时,如何在数据表中应用 Vuetify 搜索