JavaScript入門講座

Home > documentオブジェクト > fgColorプロパティ

fgColorプロパティ

documentオブジェクトのfgColorプロパティはテキストの色を返します。

書式document.fgColor
ブラウザInternet ExplorerFireFoxChromeSafari
テキストの色
使用例ボタンによりテキストの色を変える。

<html>
<head>
<title>JavaScript fgColor</title>
<script> 
function changeFg(color){ 
	document.fgColor = color;
}
</script>
</head>
<body>
<form name="fm">
現在のテキストの色を変える<br>
<input type="button" value="赤色" onclick="changeFg('red')">
<input type="button" value="青色" onclick="changeFg('blue')">
<input type="button" value="黄色" onclick="changeFg('yellow')">
<input type="button" value="緑色" onclick="changeFg('green')">
</form>
</body>
</html>
						
関連メンバ
alinkColorアクティブリンクの色
linkColorリンクの色
vlinkColor既にいったことのあるリンクの色
bgColor背景の色