实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>春节倒计时</title> <style type="text/css"> .a{width: 1000px; height:800px; margin: 0 auto; margin-top: 30px; background-image:url(images/20190121.jpg); } </style> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script type="text/javascript"> $(function(){ function Ro(){ var d=Date.parse("Feb 05,2019"); var date=new Date(); var dd=date.getTime(); var rd=Math.floor((d-dd)/1000); var days=Math.floor(rd/86400); var hours=Math.floor(rd%86400/3600); var minus=Math.floor(rd%3600/60); var secos=Math.floor(rd%60); $("span").text(days+"天"+hours+"小时"+minus+"分钟"+secos+"秒") } setInterval(Ro,1000); }) </script> <style type="text/css"> .box{margin: 0 auto;margin-top: 20px;text-align: center;} .box{width: 280px;height: 280px;line-height: 140px;border-radius: 50%;} .text{text-shadow: 1px 2px #5b149e;} </style> </head> <body> <div class='a'> <div class="box text">2019年农历春节倒计时: <div> <span ></span></div> </div> </div> <script> $(function(){ console.log($('.box').css('height')) $('.box').css('background','red') $('.box').css({'font-weight':'bold','font-size':'19px','color':'#fff'}) $('.box').addClass('text') }) </script> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例