Created
October 19, 2017 08:32
-
-
Save salipro4ever/aacdd45a25315e0fa4320ad4b5429048 to your computer and use it in GitHub Desktop.
Create jquery plugin (faster)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.digits = function(){ | |
| return this.each(function(){ | |
| $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); | |
| }) | |
| } | |
| You could then use it like this: | |
| $("span.numbers").digits(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment