<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>首页</title>
<style>
.father{
border: 1px solid #FF0000;
margin: auto;
}
</style>
<script>
var time;
function init(){
//定时器
time = setInterval("showImg()", 3000); //参数 1,调用的方法 2.时间
}
function showImg(){
document.getElementById("img2").style.display = "block";
clearInterval(time);
time = setInterval("noShowImg()", 3000);
}
function noShowImg(){
document.getElementById("img2").style.display = "none";
clearInterval(time);
}
</script>
</head>
<body onload="init()">
<div class = "father">
<img src="../img/f001a62f-a49d-4a4d-b56f-2b6908a0002c_g.jpg" style="display: none" width="100%" id="img2"/>
</div>
</body>
</html>
原生js简单实现广告图片弹出消失
最新推荐文章于 2022-12-07 20:33:55 发布