week2day1 web前端 删除广告训练

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
position: relative;
}
#hide{
display: none;
}
#ad{
height: 100px;
background-color:pink ;
}
#ad img{
width: 100%;
height: 100%;
}
#ad #close{
position: absolute;
top: 10px;
right: 15px;
width: 30px;
height: 30px;
background-color: gray;
text-align: center;
line-height: 30px;
}
#content{
height: 400px;
background-color: blue;
}
</style>
</head>
<body>
<div id="ad">
<img src="img/slide-1.jpg"/>
<div id="close" onclick="close1()">
X
</div>
</div>
<div id="content"></div>
<script type="text/javascript">
function close1(){
var adNode = document.getElementById('ad')
// adNode.parentNode.removeChild(adNode)
// 直接移出指定标签
// adNode.remove()
adNode.style.display = 'none'
}
</script>
</body>
</html>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容