1 <body> 2 <div id="ad1" class="ad1"> 3 <img src="http://p2.ifengimg.com/a/2017/0104/fb96dfa4d829fd1size22_w120_h164.png" style=" 100%;height: 100%" alt=""> 4 </div> 5 <div id="ad2" class="ad2"> 6 <button class="close" id="close">关闭</button> 7 <img src="http://p2.ifengimg.com/a/2017/0104/fb96dfa4d829fd1size22_w120_h164.png" style=" 100%;height: 100%" alt=""> 8 </div> 9 <script> 10 var close=document.getElementById('close'); 11 var ad1=document.getElementById('ad1'); 12 var ad2=document.getElementById('ad2'); 13 close.addEventListener('click',function () { 14 ad1.style.display='none'; 15 ad2.style.display='none'; 16 }) 17 </script> 18 </body>