Skip to content

dperish/nTh.js

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

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)

About

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)

Resources

License

Stars

Watchers

Forks

Packages

No packages published