很多地方都可以看到这样的效果,网页中的一个链接,鼠标放上去就变成另一颜色。要怎么实现呢?
这里我们只需要在Head内预先定义两个类,分别定义了两种颜色,这在后面的HTML源文件中会用到这个颜色的定义:
<style>
.normal {color:red;}
.start {color:blue;}
</style>
然后我们在要改变的字前后加上下面的代码:
<SPAN onmouseover = "this.className = 'normal'"
onmouseout = "this.className='start'" class=start> here </SPAN>
这里的“class=start”是将这行字的默认值设为 start {color:blue;},要是不加上这句 的话,你这行字的颜色就会变成HTML预先设定的数值。