Capitalize First Letter JavaScript Example

Today, We want to share with you Capitalize First Letter JavaScript Example.In this post we will show you javascript capitalize, hear for javascript capitalize first letter of each word in array we will give you demo and example for implement.In this post, we will learn about javascript capitalize first letter with an example.

Capitalize First Letter JavaScript Demo

javascript capitalize first letter

simple Convert the first character of “hello infinityknow.com examples” to uppercase:

function capitalizeFirstLetter(mystr) {
    return mystr.charAt(0).toUpperCase() + mystr.slice(1);
}

javascript capitalize

How To Capitalize The First Letter Of A String using JavaScript

var firstLetter = string.charAt(0);

Capitalizing first letter of each word in string

Simple JavaScript example to Capitalize First Letter of each particuler word of a given string.

READ :  Vuejs Expressions – Numbers Strings Objects Array eval using Vuejs

HTML Code:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>capitalize first letter javascript.</title>
</head>
<body>
//This Example Output Here...
</body>
</html>

JavaScript Code:

function capitalize_first_letter(mystr) 
{
    mystr = mystr.split(" ");

    for (var i = 0, x = mystr.length; i < x; i++) {
        mystr[i] = mystr[i][0].toUpperCase() + mystr[i].substr(1);
    }

    return mystr.join(" ");
}

console.log(capitalize_first_letter("InfinityKnow Capitalize First Letter of each sentence using JavaScript."));

javascript capitalize Example

CSS capitalize first letter

<p>InfinityKnow Capitalize First Letter of each sentence using CSS</p>

p:first-letter {
    text-transform:capitalize;
}

jQuery 15 Powerful Tips and Tricks for Developers and Web Designer

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about javascript capitalize first letter of each word.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

READ :  VueJS Nested Components vue inside Components Example

Add a Comment

Your email address will not be published. Required fields are marked *