Created
January 17, 2017 10:45
-
-
Save arslanfarooq/f6079b4442261ad67575ac282ec2c86b to your computer and use it in GitHub Desktop.
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
| <script type="text/javascript"> | |
| jQuery(document).ready(function($) { | |
| var ele = $('h3'); | |
| ele.each(function() { | |
| $(this).text(toProperCase($(this).text())); | |
| }); | |
| function toProperCase(str) | |
| { | |
| var noCaps = ['of','a','the','and','an','am','or','nor','but','is','if','then', | |
| 'else','when','at','from','by','on','off','for','in','out','to','into','with']; | |
| return str.replace(/\w\S*/g, function(txt, offset){ | |
| if(offset != 0 && noCaps.indexOf(txt.toLowerCase()) != -1){ | |
| return txt.toLowerCase(); | |
| } | |
| return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); | |
| }); | |
| } | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment