標籤:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>css3</title><style type="text/css">*{ margin:0; padding: 0;}ul,li{ list-style: outside none none;}.box{ width: 600px; margin: 0 auto;}.first_banner{ margin: 40px 0; width: 100%; height: 170px; background: #ddd; display: none; position: relative;}.first_banner img{ width: 100%;}.first_banner time{ position: absolute; right: 10px; top: 10px; font-family: "Microsoft Yahei";}</style></head><body><div class="box"> <input type="hidden" class="first_click" value="按鈕" /> <div class="first_banner"> <time></time> <img src="img/1.jpg" alt=""> </div></div><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript"> $(function(){ var timer = null; var s = 5; function myFn(){ $(‘time‘).html(s+"秒"); s--; if(s<0){ clearInterval(timer); $(‘.first_banner‘).hide(); } }; $(‘.first_click‘).one(‘click‘,function(){ $(‘.first_banner‘).show(); myFn(); timer = setInterval(myFn,1000); }).click(); });</script></body></html>
類比網頁啟動頁