How To Capitalize The First Letter Of Each Word Using jQuery

In this post, we will learn about how to capitalize the first letter of each word. Here is the simple example of how to do this using jquery. In this example first we need to add one js file for accessessing the css() function. Let's start coding.

First we need to add the below js file for accessing the  css() function.

  1. <script src=""
Write the below complete source code for css() function, add text and transform style in HTML textbox.
  1. <!DOCTYPE html>  
  3. <html>  
  4. <head>  
  5.     <script src=""></script>  
  6.     <script>  
  7.         $(document).ready(function () {  
  8.             $("#test").keyup(function () {  
  9.                 $('#test').css('textTransform', 'capitalize');  
  10.             });  
  11.         });  
  12.     </script>  
  13. </head>  
  14. <body>  
  15.     <h1>First Letter Capital</h1>  
  16.     <input type="text" id="test" />  
  18. </body>  
  19. </html> 
The above code works when the user starts writing in a textbox, then the textbox keyup event is fired and startd capitalizing the textbox text automatically. Try this code in and html page and see the result.