How to change the font color of a text using JavaScript?

JavascriptWeb DevelopmentFront End Technology

To change the font color of a text, use the fontcolor() method. This method causes a string to be displayed in the specified color as if it were in a <font color="color"> tag. 

Example

You can try to run the following code to change the font color of a text using JavaScript −

Live Demo

<html>
   <head>
      <title>JavaScript String fontcolor() Method</title>
   </head>

   <body>
      <script>
         var str = new String("Demo Text");
         document.write(str.fontcolor( "blue" ));
         alert(str.fontcolor( "blue" ));
      </script>
   </body>
</html>
raja
Published on 18-Jan-2018 16:51:39
Advertisements