1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
<!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta charset="utf-8">
<title>Forum jQuery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/headjs/0.99/head.min.js"></script>
<!-- Tablesorter: required -->
<link rel="stylesheet" href="tablesorter/css/theme.blue.css">
<script src="tablesorter/js/jquery.tablesorter.js"></script>
<script src="tablesorter/js/jquery.tablesorter.widgets.js"></script>
<script type="text/javascript">
$(function() {
$("table").tablesorter({
theme: 'blue',
widthFixed : true,
widgets: ["zebra", "filter"],
widgetOptions : {
filter_cssFilter : 'tablesorter-filter',
filter_childRows : false,
filter_hideFilters : false,
filter_ignoreCase : true,
filter_reset : '.reset',
filter_searchDelay : 300,
filter_startsWith : false,
filter_hideFilters : false,
filter_functions : {
// 0 : true,
1 : true,
3 : true,
2 : {
"< 200" : function(e, n, f, i) { return n <=200; },
"50 - 100" : function(e, n, f, i) { return n >= 50 && n <=100; },
"0 - 50" : function(e, n, f, i) { return n >= 0 && n <=50; },
}
}
}
});
});
head.js(
"http://code.jquery.com/jquery-2.1.0-beta1.js", function(){
$( function(){
var total = 0,
sousTotal = 0,
jObjTotal = $( "#data tfoot th:eq(0)" ),
jObjTbodyTr = $( "#data tbody tr" );
$( "#data tfoot th.total" ).each( function( i, item ){
sousTotal = 0;
jObjTbodyTr.each( function( j, jtem ){
sousTotal += parseFloat( $( "td.sum:eq( " + i + " )", jtem ).text() ) || 0;
});
$( item ).text( sousTotal );
jObjTotal.text( ( total += sousTotal ) );
});
});
$( window ).load( function(){
});
});
</script>
</head>
<body>
<table border="1" width="500" class="tablesorter" id="data">
<thead>
<tr align="center">
<th>Name</th>
<th>Age</th>
<th>Weight</th>
<th>Number</th>
</tr>
</thead>
<tfoot>
<tr align="center">
<th ></th>
<th class="total"></th>
<th class="total"></th>
<th class="total"></th>
</tr>
</tfoot>
<tbody>
<tr align="center">
<td>Joe</td>
<td class="sum">11</td>
<td class="sum">200</td>
<td class="sum">1</td>
</tr>
<tr align="center">
<td>Jack</td>
<td class="sum">29</td>
<td class="sum">100</td>
<td class="sum">1</td>
</tr>
<tr align="center">
<td>Jim</td>
<td class="sum">32</td>
<td class="sum">50</td>
<td class="sum">2</td>
</tr>
<tr align="center">
<td>John</td>
<td class="sum">15</td>
<td class="sum">25</td>
<td class="sum">1</td>
</tr>
</tbody>
</table>
</body>
</html> |