| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Stupid jQuery table sort</title> |
| •5 |
<script src="/usr/share/javascript/jquery/jquery.min.js"></script> |
| 6 |
<script src="/usr/share/javascript/jquery-stupidtable/stupidtable.js?dev"></script> |
| 7 |
<script> |
| 8 |
$(function(){ |
| 9 |
$("table").stupidtable(); |
| 10 |
}); |
| 11 |
</script> |
| 12 |
<style type="text/css"> |
| 13 |
table { |
| 14 |
border-collapse: collapse; |
| 15 |
} |
| 16 |
th, td { |
| 17 |
padding: 5px 10px; |
| 18 |
border: 1px solid #999; |
| 19 |
} |
| 20 |
th { |
| 21 |
background-color: #eee; |
| 22 |
} |
| 23 |
th[data-sort]{ |
| 24 |
cursor:pointer; |
| 25 |
} |
| 26 |
tr.awesome{ |
| 27 |
color: red; |
| 28 |
} |
| 29 |
</style> |
| 30 |
</style> |
| 31 |
</head> |
| 32 |
|
| 33 |
<body> |
| 34 |
|
| 35 |
<h1>Stupid jQuery table sort!</h1> |
| 36 |
|
| 37 |
<p>This example shows how a sortable table can be implemented with very little configuration. Simply specify the data type on a <code><th></code> element using the <code>data-sort</code> attribute, and the plugin handles the rest.</p> |
| 38 |
|
| 39 |
<table> |
| 40 |
<thead> |
| 41 |
<tr> |
| 42 |
<th data-sort="int">int</th> |
| 43 |
<th data-sort="float">float</th> |
| 44 |
<th data-sort="string" data-sort-onload="yes">string</th> |
| 45 |
</tr> |
| 46 |
</thead> |
| 47 |
<tbody> |
| 48 |
<tr> |
| 49 |
<td>15</td> |
| 50 |
<td>-.18</td> |
| 51 |
<td>banana</td> |
| 52 |
</tr> |
| 53 |
<tr class="awesome"> |
| 54 |
<td>95</td> |
| 55 |
<td>36</td> |
| 56 |
<td>coke</td> |
| 57 |
</tr> |
| 58 |
<tr> |
| 59 |
<td>2</td> |
| 60 |
<td>-152.5</td> |
| 61 |
<td>apple</td> |
| 62 |
</tr> |
| 63 |
<tr> |
| 64 |
<td>-53</td> |
| 65 |
<td>88.5</td> |
| 66 |
<td>zebra</td> |
| 67 |
</tr> |
| 68 |
<tr> |
| 69 |
<td>195</td> |
| 70 |
<td>-858</td> |
| 71 |
<td>orange</td> |
| 72 |
</tr> |
| 73 |
</tbody> |
| 74 |
</table> |
| 75 |
|
| 76 |
</body> |
| 77 |
</html> |