Correction status:Uncorrected
Teacher's comments:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>倒计时跳转</title> <style type="text/css"> p{width:300px;height: 50px;margin: 100px auto;} span{display: inline-block;height:50px;width: 50px;line-height: 50px;font-size: 30px;color:#f00;text-align: center} </style> </head> <body> <p> 还剩<span>5</span>跳转至<a href="http://www.baidu.com">百度</a> </p> <div style="width:100px; height:100px" ></div> <script type="text/javascript"> var i=4; var Espan=document.getElementsByTagName('span')[0]; function fn(){ if(i>0){ Espan.innerHTML=i; i--; }else{ window.location.href = 'http://www.baidu.com'; } } setInterval('fn()',1000) </script> </body> </html>
点击 "运行实例" 按钮查看在线实例