案例分析:点击按钮后,在网页上指定区域,提示错误信息!5秒后,错误信息提示自动消失!

    <script languag="javascript" type="text/javascript">
var clearId;
function test(){
document.getElementById("showMsg").style.cssText="width:200px;height:50px;left:600px;top:100px;position:absolute;background-color:red;";
document.getElementById("showMsg").innerText = "输入的有错误!请重新输入!";
clearId = setTimeout("autoClearError()",5000);
} function autoClearError(){
document.getElementById("showMsg").style.cssText="";
document.getElementById("showMsg").innerText = ""
clearTimeout(clearId);
}
</script>
</head>
<body>
<input type="button" value="删除" onclick="test();" />
<div id="showMsg"></div>
</body>
05-01 06:42