- zackmartin liked this
- radiantcircle-if liked this
- yakult-tests reblogged this from shythemes
- nonspaced liked this
- saltpinched liked this
- musicalmedli liked this
- spacedandelions liked this
- nanamiiinnnn liked this
- nubeculae reblogged this from shythemes
- jumyoungs liked this
- bloomdictator liked this
- karaelnsn liked this
- rosettyller reblogged this from glenthemes
- sulkers liked this
- peacefulthemerecs reblogged this from shythemes
- mille-fleurs reblogged this from xuethms
- arianagrandre liked this
- watershed liked this
- pneuma-themes liked this
- dxmain reblogged this from shythemes
- valleysims liked this
- dustyresources reblogged this from xuethms
- sheathemes liked this
- zicocodes reblogged this from xuethms
- ribhinnog liked this
- phantomcodes reblogged this from miyazakio
- miyazakio reblogged this from xuethms
- petutunias reblogged this from supportcontentcreators
- uvena liked this
- supportcontentcreators reblogged this from shythemes
- anbi liked this
- patr-onus liked this
- ocida-ref reblogged this from seyche
- armandeos liked this
- hualians liked this
- archonfurina reblogged this from seyche
- unsearch reblogged this from seyche
- ekourege liked this
- elevenriver liked this
- seyche reblogged this from xuethms
- officialpusheen liked this
- shythemes posted this
- Show more notes
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
- add the class “notecount” to your note count links
- make sure the container class “content” above matches the container element in your particular theme
- include it in your infinite scroll function if you’re using one