使用jquery查找datatable的表格单元格的内部值

时间:2014-08-07 20:37:07

标签: javascript jquery datatable cell html-table

我定义了以下数据表。

问题 - 绘制数据表后,当我从滑块jquery输入中检索值时,我收到span和整个文本而不是值。我如何只检索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的滑块jquery,但找不到该值。

帮助赞赏,jQuery的新手。

1 个答案:

答案 0 :(得分:0)

此选择有效。输入包含在表格单元格中包含的范围内。 $(本).closest( 'TR')找到( '#pointSlider')VAL()。