2013-03-24 150 views
2

對不起,這個愚蠢的問題來了,但我一直在努力奮鬥幾個小時沒有成功。 我的示例表未被排序。這兩個.js文件都位於與.shtml文件本身相同的目錄中。tablesorter沒有排序

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us"> 
<head> 
<script type="text/javascript" src="jquery-latest.js"></script> 
<script type="text/javascript" src="jquery.tablesorter.js"></script> 
<script type="text/javascript"> 
$(document).ready(function()  
    {  
        $("#myTable").tablesorter();  
    }  
);  
</script> 
</head> 
<body> 
<table id="myTable" class="tablesorter"> 
    <thead> 
    <tr> 
    <th>Test1</th> 
    <th>Test2</th> 
    </tr> 
    </thead> 
    <tbody> 
    <tr> 
    <td>1</td> 
    <td>1622</td> 
    </tr> 
    <tr> 
    <td>2</td> 
    <td>2634</td> 
    </tr> 
    </tbody> 
</table> 
</body> 
</html> 

回答

4

也許你有錯誤的jquery和tablesorter副本?它似乎工作得很好,使用jquery和tablesorter的實際版本鏈接從他們各自的網站。

http://code.jquery.com/jquery-1.9.1.js
http://mottie.github.com/tablesorter/js/jquery.tablesorter.js

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us"> 
<head> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script type="text/javascript" src="http://mottie.github.com/tablesorter/js/jquery.tablesorter.js"></script> 
<script type="text/javascript"> 
$(document).ready(function() 
    { 
     $("#myTable").tablesorter(); 
    } 
); 
</script> 
</head> 
<body> 
<table id="myTable" class="tablesorter"> 
    <thead> 
    <tr> 
    <th>Test1</th> 
    <th>Test2</th> 
    </tr> 
    </thead> 
    <tbody> 
    <tr> 
    <td>1</td> 
    <td>1622</td> 
    </tr> 
    <tr> 
    <td>2</td> 
    <td>2634</td> 
    </tr> 
    </tbody> 
</table> 
</body> 
+0

感謝。恐怕必須有一個通用的配置問題。你提供的資源不能正常工作... – 2013-03-24 02:17:55

+0

是的,那麼不確定。這對Chrome和IE8都適用,但我必須允許IE8中的腳本。 – Ngenator 2013-03-24 02:28:38

+3

務必使用tablesorter的[this fork](http://mottie.github.com/tablesorter/docs/)。它修復了與原始版本有關的各種問題,而現在這種版本尚未更新多年。 – 2013-03-24 02:44:01