McClaud McClaud - 1 year ago 119
Javascript Question

singular plural depending on state

I'm using the script MixItUp for filtering and sorting nodes in xml files. I have a script for counting the nodes which changes upon filtering - and the count changes as it should. What the script (read: I) don't accomplish is the correct singular or plural unit after the count.

My script looks like this:

<script type="text/javascript">$(function(){$('#miucontainer').on('mixEnd',function(e,state){$('.mixcount').html(state.totalShow+' players');});});</script>

I aim for a simple solution. Thank you in advance. :o)

Answer Source

Well, you need to conditionally output the 's', which you're not currently doing.

$('.mixcount').html(state.totalShow+' player'+(state.totalShow !== 0 ? 's' : ''));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download