Latest web development tutorials

JavaScript fontcolor () method

String Object Reference JavaScript String Object

Definition and Usage

fontcolor () method is used in accordance with the specified color to display the string.

This method returns a string plus <font> tag, as follows:

<Font color = "colorvalue"> string </ font>

grammar

string.fontcolor(color)

参数 描述
color 必需。为字符串规定 font-color。该值必须是颜色名(red)、RGB 值(rgb(255,0,0))或者十六进制数(#FF0000)。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support fontcolor () method.


Examples

Examples

Use the green display strings:

<script>

var str = "Hello world!";
document.write(str.fontcolor("green"));

</script>

try it"


String Object Reference JavaScript String Object