Create a font element from string object and set the color in JavaScript

Description

The following code shows how to create a font element from string object and set the color.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var myString = new String();<!--   w w w  .j  av  a  2  s.  c  o m-->
myString = "java2s.com";
document.writeln(myString.fontcolor("red"));


</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Create a font element from string object and set the color in JavaScript