How to set the capitalization of a text with JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

To set the capitalization, use the textTransform property in JavaScript. Set it to capitalize, if you want the first letter of every word to be a capital letter.


You can try to run the following code to return the capitalization of a text with JavaScript −

<!DOCTYPE html>
      <button onclick = "display()">Capitalize Text</button>

      <div id = "myID">
         This is demo text! This is demo text!

         function display() {
            document.getElementById("myID").style.textTransform = "capitalize";
Published on 27-Feb-2018 08:08:54