Skip to content

Instantly share code, notes, and snippets.

Created May 22, 2016 23:29
Show Gist options
  • Save anonymous/9e00d06e6d4e9a06f6e2d3d0843b9dea to your computer and use it in GitHub Desktop.
Save anonymous/9e00d06e6d4e9a06f6e2d3d0843b9dea to your computer and use it in GitHub Desktop.
<script>
$("tbody tr").click(function() {
if ($(this).parents().hasClass('selected')) {
$(this).prependTo($('.original'));
} else {
$(this).prependTo($('.selected'));
}
calculate();
})
var calculate = function () {
var sum = $('.selected tr td:nth-child(2)').toArray().map(function (td) {
return $(td).text();
}).reduce(function (sum, i) {
return sum + parseInt(i);
}, 0);
$('.total').text(sum);
};
var t = $('table');
var c = $('.column');
calculate();
$("#original").tablesorter( {sortList: [[1,0]]} );
$("#selected").tablesorter();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment