以下是我的html页面的格式:



<table id = 'myTable' class='table table-striped tablesorter'>
	<thead>
	    <tr>
	        <th>Wild</th>
	        <th>Release Date</th>
	        <th>CVE</th>
	        <th>QH Detection Name</th>
	        <th>Comments</th>
	    </tr>
	</thead>
	<tr class='info'>
	    <td width='3%'><img src='ex.png' alt='' border=3 height=25 width=25></img></td>
	    <td width='10%'>03/11/2015</td>
	    <td width='12%'>CVE-2015-1623</td>
	    <td width='17%'>
	        <li>abc</li>
	        <li>xyz</li>
	        <li>pqr</li>
	        </ul>
	    </td>
	    <td width='58%'>
	        <b>Description: </b><br>Microsoft Internet Explorer 11 allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) via a crafted web site, aka "Internet Explorer Memory Corruption Vulnerability".
	        VPS release: 150311-00
	        <br><b>Link: </b><br>
	        <ul>
	            <li><a href =http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-1623 target ='_blank'>http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-1623<br></a></li>
	        </ul>
	    </td>
	</tr>
	.......
</table>





JS页面:



$(document).ready(function()
    {
        $("#myTable").tablesorter();
    }
);
$(document).ready(function()
    {
        $("#myTable").tablesorter( {sortList: [[1,0],[2,0]]} );
    }
); 





我正在使用表排序器插件,但是表未排序。
我第一次使用tablesorter插件,我做了tablesorter的文档中提到的方法,但是它不起作用

最佳答案

如@doveyg所述,不需要脚本的第一块。实际上,由于tablesorter已在该表上初始化,因此第二个代码块中包含的选项将被完全忽略,这就是为什么该表未排序的原因。

所有你需要的是:

$(function()
    {
        $("#myTable").tablesorter( {sortList: [[1,0],[2,0]] } );
    }
);

10-05 20:16
查看更多