html
1<p class="taimer_text">キャンペーン終了まで</p> 2 <div id="countdown"> 3 </div> 4 <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> 5 <script> 6 function countdowntimer(){ 7 var countdown = setInterval(function(){ 8 var today = new Date();//今の日時 9 var targetDay = new Date('2020/04/18 21:00:00');//ターゲットの日時 10 var daysBetween = Math.ceil((targetDay - today) / (24*60*60*1000));//経過日時を1日のミリ秒で割る 11 var remainDay = (targetDay - today);//残り日時 12 if (remainDay >= 0){//もし残りの日時が0より多かったら、 13 var h = Math.floor(remainDay / 3600000);//残りの日時を1hで割った時間を取得(1h=3600000ms) 14 var h1 = h % 24;//hを24で割った余り 15 var m = Math.floor((remainDay - h * 3600000) / 60000);//分を取得(1分=60000 ms) 16 var s = Math.round((remainDay - h * 3600000 - m * 60000) / 1000);//秒を取得(1秒=1000ms) 17 $("#countdown").text( daysBetween + "日と" + h1 + "時間" + m + "分" +s + "秒!!");//htmlに出力 18 if ((h == 0) && (m == 0) && (s == 0)) {//指定の日時が来たら、 19 clearTimeout(countdown);//ウントダウンを止める 20 $("#countdown").text("お正月です");//htmlに出力 21 } 22 }else{//指定の日時が過ぎてもテキストを表字させる用 23 $("#countdown").text("キャンペーン実施中"); 24 } 25 }, 1000);//処理を1秒後に予約 26 } 27 28 countdowntimer(); 29 30 </script> 31 32 33
css
1#countdown { 2 font-weight: bold; 3 text-align: center; 4 color: #fff; 5 background-color: #940e35; 6 margin: 0; 7 font-size: 3rem; 8 } 9 10 .taimer_text { 11 padding-top: 0.5rem; 12 font-size: 1.5rem; 13 color: #FFE344; 14 font-weight: bold; 15 text-align: center; 16 margin: 0; 17 background-color: #940e35; 18 } 19 20
こちらなのですが、なぜか
html
1<div id="countdown"></div>
が表示されません。
index.htmlファイルだと表示されたのですが
index.tpl のように拡張子がtplになるとなぜか表示されません...
こちらの原因わかる方いますでしょうか?
ちなみに以下のメディアスクリーン内に記述し、実際の幅を750pxより小さくしましたが表示がされませんでした
css
1@media screen and (min-width:0px) and (max-width: 750px)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。