DIV显示几秒然后删除,实现小提示

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
 #msg{ background-color:#900; 200px; height:200px; position:absolute; margin:-100px 0 0 -100px; top:50%; left:50%; display:none;}
</style>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" >
 function showMsg(){
  $("<div id='msg'></div>").appendTo("body");
  $("#msg").fadeIn("fast",function(){
   window.setTimeout(function(){
     $("#msg").fadeOut("fast",function(){
      $("#msg").remove();
     })       
   },3000)        
  })
  
 }
</script>
<title>无标题文档</title>
</head>

<body>
<input type="button" onclick="showMsg()" value="显示" />

</body>
</html>

原文地址:https://www.cnblogs.com/webblog/p/1541245.html