Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery tablesorter-Colspan排序第二列_Jquery_Tablesorter - Fatal编程技术网

jQuery tablesorter-Colspan排序第二列

jQuery tablesorter-Colspan排序第二列,jquery,tablesorter,Jquery,Tablesorter,下表增强了jquery tablesorter: <table> <thead> <tr> <th colspan="2">Name</th> <th>Value</th> </tr> </thead> <tbody> <tr>

下表增强了jquery tablesorter:

<table>
    <thead>
        <tr>
            <th colspan="2">Name</th>
            <th>Value</th>
        </tr>
    </thead>

    <tbody>
        <tr>
            <td><input type="checkbox" name="london" value="1" /></td>
            <td>London</td>
            <td>124</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="oslo" value="1" /></td>
            <td>Oslo</td>
            <td>66</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="athens" value="1" /></td>
            <td>Athens</td>
            <td>87</td>
        </tr>
    </tbod>
</table>

名称
价值
伦敦
124
奥斯陆
66
雅典
87
我现在的问题是,如果单击“Name”列标题,表将不会排序,因为tablesorter会尝试对第一列进行排序,这是每行中的复选框


有没有办法告诉tablesorter,将第二列而不是第一列排序?

我没有回答你的问题,但我可以告诉你另一种方法。不要使用colspan=“2”,而是使用以下代码

<thead>
    <tr>
    <th style="display:none"></tr>
    <th>Name</th>
    <th>Value</th>
    </tr>
</thead>

名称
价值

希望它能解决您的问题。

我尝试了一些解决方案,但唯一有效的方法是在第一个td列中添加一个隐藏的跨距,其中第二列的值为:

<table>
    <thead>
        <tr>
            <th colspan="2">Name</th>
            <th>Value</th>
        </tr>
    </thead>

    <tbody>
        <tr>
            <td><span style="display: none;">London</span><input type="checkbox" name="london" value="1" /></td>
            <td>London</td>
            <td>124</td>
        </tr>
        <tr>
            <td><span style="display: none;">Oslo</span><input type="checkbox" name="oslo" value="1" /></td>
            <td>Oslo</td>
            <td>66</td>
        </tr>
        <tr>
            <td><span style="display: none;">Athens</span><input type="checkbox" name="athens" value="1" /></td>
            <td>Athens</td>
            <td>87</td>
        </tr>
    </tbod>
</table>

名称
价值
伦敦
伦敦
124
奥斯陆
奥斯陆
66
雅典
雅典
87

您好,我以前尝试过这个解决方案,但问题是,一行中的th比td多,因此表被破坏。th列将比td多。U r每行有3个td标签。所以,添加第三个标记并隐藏第一个标记。名称值这是第3个标记(我没有使用colspan)复选框,它有3个td列。@Krishna bernhard的意思是视觉上的,而不是逻辑上的。我也遇到了同样的问题。当第一个未显示时,以下两个将被推到左侧,这将在视觉上“销毁”表格。