【实例名称】
鼠标移入移出时颜色变化
【实例描述】
当用户将鼠标移动到按钮或链接上时.为了突出显示用户的选择,会改变链接和按钮的颜色。默认链接的颜色是自动变化的,本例学习如何手动为按钮设置这种效果。
【实例代码】
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>标题页</title>
</head>
<body>
<input type="submit" value="把鼠标移动这里"
name="btn1" onMouseOut=this.style.color="blue"
onMouseOver=this.style.color="red" >
</body>
</html>
【运行效果】

【难点剖析】
本例的重点是鼠标事件的应用。当鼠标移动到控件上时,触发了‘'onMouseOver”事件,当鼠标移走时,触发“onMouseOut”事件。两个事件的响应都是使用“style.color”改变控件的颜色。