The fontcolor() method can display a string in a specified color.
The fontcolor() method can display a string in a specified color.
This method returns the string embedded in the <font> tag, like this:
<font color="colorvalue">string</font>
string.fontcolor("color")
Parameter | Require | Description |
---|---|---|
color | Required. | A color value. The value can be a color name (e.g. red), an RGB value (e.g. rgb(255,0,0)), or a hex number (e.g. #FF0000)e |
A string embedded in the <font> tag
Display the text in green color:
//display a string in a specified color. var str = "Hello World!"; var result = str.fontcolor("green"); console.log(result);/*from ww w . ja v a2s. c o m*/