Created
May 22, 2016 23:29
-
-
Save anonymous/9e00d06e6d4e9a06f6e2d3d0843b9dea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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