样式代码如下:
<!DOCTYPE html>
<html>
<head>
<title>动态提示信息</title>
<meta charset="utf-8"/>
<style type="text/css">
p{
width:100px;
margin:10px auto;
/*border:1px solid red;*/
text-align:center;
}
.hide{
display:none;
}
.show{
display:block;
}
</style>
<script type="text/javascript">
//显示消息,过两秒后再隐藏
function del(){
var msg = document.getElementById("msg");
msg.className = "show";
var id = setTimeout(function(){
msg.className = "hide";
clearTimeout(id);
},2000);
}
</script>
</head>
<body>
<p><button οnclick="del()">删除</button></p>
<p class="hide" id="msg">操作成功!</p>
</body>
</html