<script language="JavaScript">
var hex = 255; // 初始颜色值.
function fadetext(){
if(hex>0) {
hex -= 5; // 加深文字的颜色
document.getElementById("sample").style.color="rgb("+hex+","+hex+","+hex+")";
setTimeout("fadetext()",20);
}
else
hex = 255; // 重置颜色值
}
</script>
<div id="sample"><h1>DOM实现淡出的效果(IE5.5、NS6、Firefox1.0、Opera8)</h1></div>
<button onClick="fadetext()">运行效果</button>