TwentyLe TwentyLe - 1 month ago 15
jQuery Question

Jquery Tablesorter not working! What's wrong with that?

I'm new to Jquery and I'm trying to use Jquery Tablesorter plugin and I've tested it in a simple html file as below but it is not working. All I have seen in browser is only a plain table with no sorting, none clickable header, it doesn't look like what I seen on Jquery Tablesorter home page. I don't know what's wrong with my html. I have placed 2 jquery files in same folder with this html file. Please advise!

<html>
<head>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
</script>
</head>
<body>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Last Name</th>
<th>First Name</th>
<th>Email</th>
<th>Due</th>
<th>Web Site</th>
</tr>
</thead>
<tbody>
<tr>
<td>Smith</td>
<td>John</td>
<td>jsmith@gmail.com</td>
<td>$50.00</td>
<td>http://www.jsmith.com</td>
</tr>
<tr>
<td>Bach</td>
<td>Frank</td>
<td>fbach@yahoo.com</td>
<td>$50.00</td>
<td>http://www.frank.com</td>
</tr>
<tr>
<td>Doe</td>
<td>Jason</td>
<td>jdoe@hotmail.com</td>
<td>$100.00</td>
<td>http://www.jdoe.com</td>
</tr>
<tr>
<td>Conway</td>
<td>Tim</td>
<td>tconway@earthlink.net</td>
<td>$50.00</td>
<td>http://www.timconway.com</td>
</tr>
</tbody>
</table>
</body>
</html>

Answer

Here's the working fiddle link. You forgot to add the tablesorter js and tablesorter css which I added in external resources in jsfiddle. You can check it.

http://jsfiddle.net/BKgue/2/

Comments