代码语言:javascript复制
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
*{padding: 0px;margin: 0px;}
div
{
position: fixed;
left: 0px;
bottom: 0px;
}
div>img:first-child
{
position: absolute;
right: 0px;
top: -17px;
}
</style>
</head>
<body>
<div>
<img src="images/close.jpg" alt="">
<img src="images/sina-ad.png" alt="">
</div>
<script type="text/javascript">
let qq=document.querySelector("div>img:first-child");
qq.onclick=function()
{
//找到img的父元素div
let ww=this.parentNode;
//然后找到div的父元素(body)执行删掉div的操作。
ww.parentNode.removeChild(ww);
}
</script>
</body>
</html>