Advertisement
Guest User

percentsortbyvote.js

a guest
Nov 18th, 2015
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. $('tbody:first').append($('tbody:first > tr').sort(function(a, b) {
  2. return parseInt($('.vote-count-post',b).text(),10) - parseInt($('.vote-count-post',a).text(),10);
  3. }))
  4.  
  5. var sum = 0;
  6. $('tbody:first > tr').each(function(){
  7. sum += parseInt($('.vote-count-post',this).text(),10)
  8. }).each(function(){
  9. var vote = $('.vote-count-post',this);
  10. $('<span>').text(parseInt((+vote.text()*100)/sum)+"%").insertAfter(vote);
  11. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement