Anonymous:
hello, i was wondering if you knew how to shorten larger numbers using javascript. for example, i want to display a note count that is 1203 as 1.2k. i know it's possible, i just don't know how to do it. :(

how much do you love me

    var $container = $('.content');
   $container.find('.notecount').each(function(){
       var n = $(this).html().split(' ')[0].replace(/,/g, '');
       if (n > 999) {
           n = Math.floor(n / 100) / 10;
           $(this).text(n + 'k notes');
       }
   });

after you include this in your scripts, you need to check three things

  1. add the class “notecount” to your note count links
  2. make sure the container class “content” above matches the container element in your particular theme
  3. include it in your infinite scroll function if you’re using one
a / tutorial /
328 notes
  1. yakult-tests reblogged this from shythemes
  2. nubeculae reblogged this from shythemes
  3. rosettyller reblogged this from glenthemes
  4. peacefulthemerecs reblogged this from shythemes
  5. mille-fleurs reblogged this from xuethms
  6. dxmain reblogged this from shythemes
  7. dustyresources reblogged this from xuethms
  8. zicocodes reblogged this from xuethms
  9. phantomcodes reblogged this from miyazakio
  10. miyazakio reblogged this from xuethms
  11. petutunias reblogged this from supportcontentcreators
  12. supportcontentcreators reblogged this from shythemes
  13. ocida-ref reblogged this from seyche
  14. archonfurina reblogged this from seyche
  15. unsearch reblogged this from seyche
  16. seyche reblogged this from xuethms
  17. shythemes posted this
k.