<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery实现点击弹出层3秒后自动消失</title>
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<style type="text/css">
#dianji{text-align: center;margin-top: 50px;font-size: 30px;color:#000;display: block;}
#disappare{border:1px solid #ccc;border-radius: 5px;background: #fff;font-size: 15px;
width: 120px;height: 30px;position: fixed;top:0.5%;left: 48%;background-color: #4cae4c}
#disappare p{display:block;font-size: 16px;margin-top: 4px;width: 100%;height: 100%;color: white}
#disappare img{display:block;font-size: 16px;width: 20%;height: 100%;float: left;margin-top: -3px;margin-left: 5%;margin-right: 8%}
</style>
</head>
<body>
<div id="content">
<button id="dianji" style="font-size: 1.2em;margin-left: 45%">点击</button>
<div id="disappare" style="display:none">
<p id="msg"><img src="./对号%20(3).png">上传成功</p>
</div>
</div>
<script type="text/javascript">
$(function(){
$("#dianji").click(function(){
$("#disappare").show().delay(1500).hide(300);
});
})
</script>
</body>
</html>
例子:
| |