标签:element var display listener close idt document doc height
1 <body> 2 <div id="ad1" class="ad1"> 3 <img src="http://p2.ifengimg.com/a/2017/0104/fb96dfa4d829fd1size22_w120_h164.png" style="width: 100%;height: 100%" > 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="width: 100%;height: 100%" > 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>
为页面两边增加对联广告,增加关闭按钮,点击可以关闭对联 两边都关闭
标签:element var display listener close idt document doc height
原文地址:http://www.cnblogs.com/jiaoyue/p/6765425.html