使用自定义排序以HH:MM:SS格式

时间:2017-10-27 11:55:01

标签: javascript tablesorter

我尝试使用tablesorter以HH:MM:SS格式对时间进行排序。但是我需要一个可自定义的排序来分割和排序时间,即使时间是由微小或秒来改变

1 个答案:

答案 0 :(得分:-1)

使用Javascript进行HTML表格排序。

HTML:

{{#each loop1}}
<ul>{{val1}}
    {{#each loop2}}
        <li>{{val2}}</li>
    {{/each}}
</ul>
{{/each}}

Javascript:

<table class="table-bordered" border="1">
    <thead>
        <tr class="Headers">
            <th>Number</th>
            <th>Date start
            </th>
            <th>Date end</th>
        </tr>
    </thead>
    <tbody>
        <tr class="Entries" data-id="13">
            <td data-field-type="string">1234</td>
            <td data-field-type="date">01-04-2015</td>
            <td data-field-type="date">01-04-2015</td>
        </tr>
        <tr class="Entries" data-id="24">
            <td data-field-type="string">1352</td>
            <td data-field-type="date">04-10-2012</td>
            <td data-field-type="date">23-10-2015</td>
        </tr>
        <tr class="Entries" data-id="8">
            <td data-field-type="string">1124</td>
            <td data-field-type="date">13-05-2014</td>
            <td data-field-type="date">01-04-2015</td>
        </tr>
        <tr class="Entries" data-id="23">
            <td data-field-type="string">1652</td>
            <td data-field-type="date">07-11-2013</td>
            <td data-field-type="date">22-10-2015</td>
        </tr>
                <tr class="Entries" data-id="23">
            <td data-field-type="string">1652</td>
            <td data-field-type="date">04-12-2013</td>
            <td data-field-type="date">22-10-2015</td>
        </tr>
    </tbody>
</table>

Try it here