Capitalize first letter of string in JavaScript
home
Run
screen_rotation
fullscreen
cloud_download
<html> <head> <title>Javascript Demo</title> <script type='text/javascript'> function capitalizeFirst(str) { var result = str.charAt(0).toUpperCase() + str.slice(1); document.getElementById('myId').innerHTML = result; } </script> </head> <body> <div id="myId">hello</div> <a href='javascript:void(0);' onclick='capitalizeFirst("hello")'>Capitalize String</a> </body> </html>
<html> <head> <title>Javascript Demo</title> <script type='text/javascript'> function capitalizeFirst(str) { var result = str.charAt(0).toUpperCase() + str.slice(1); document.getElementById('myId').innerHTML = result; } </script> </head> <body> <div id="myId">hello</div> <a href='javascript:void(0);' onclick='capitalizeFirst("hello")'>Capitalize String</a> </body> </html>
Copyrights@tutorialsplane.com