<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 >运行效果</button>