nTh.js

Weighing in at 239 bytes minified, nTh.js is a javascript micro-library to return ordinal suffixes from integers

Website:https://github.com/dperish/nTh.js

nTh.js

Weighing in at 368 bytes minified, nTh.js is a javascript micro-library to return ordinal suffixes from integers (ie: 1st, 2nd, 3rd, 7th of 9).

Standard Usage - nth(int):

nth(4077); produces 4077th

Nth of Set - nth.of(int, int):

nth.of(1,3); produces 1st of 3

Via jQuery Class Selection:

  <ul>
    <li class='nth'>0</li>
    <li class='nth'>1</li>
    <li class='nth'>2</li>
    <li class='nth'>3</li>
    <li class='nth'>4077</li>
  </ui>
$(function(){
  $(".nth").html(function(i,e) {
      return nth(e);
  });
});

produces:

  • 0th
  • 1st
  • 2nd
  • 3rd
  • 4077th

Contributions

This library was written by:

Any & all contributions are welcomed.

License

nTh.js is free (as in love), and is provided under The MIT License (MIT)