英 ['kʌlə(r)]   美 [ˈkʌlɚ]  

n.<美>颜色,色彩;肤色,脸色,血色;颜料,染料;本质

v.<美>给…涂颜色;改变…的颜色;粉饰,渲染,使带上色彩;脸红

第三人称单数: colors 复数: colors 现在分词: coloring 过去式: colored 过去分词: colored

javascript color属性 语法

作用:设置文本的颜色

语法:Object.style.color=color

javascript color属性 示例

<html>
<head>
<script type="text/javascript">
function setColor()
{
document.getElementById("p1").style.color="#ff0000";
document.getElementById("p2").style.color="magenta";
}
</script>
</head>
<body>

<p id="p1">This is an example paragraph</p>
<p id="p2">This is also an example paragraph</p>

<input type="button" onclick="setColor()"
value="Change color of text" />

</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

热门推荐