<body>
<style>
#close-btn {
position: absolute;
top: 10px;
left: 232px;
width: 14px;
height: 14px;
border: 1px solid #ccc;
line-height: 14px;
cursor: pointer;
}
a:hover {
background-color: crimson;
}
</style>
<div>
<div>
<img src="图片文件/closeMark.png" alt="" id="close-btn">
</div>
<div>
<img src="图片文件/ad.gif" alt="" id="advertise">
</div>
</div>
<script>
var btn = document.querySelector('#close-btn')
var advertise = document.querySelectorAll('#advertise')
btn.onclick = function () {
advertise.style.display = none;
}
</script>
</body>
需求,想要点击图片右上角【X】那个小图标后,整个图片关闭的效果。但是搞不出来这个效果了。哪里错了吗??