0
我正在努力處理一個腳本導致通宵開放時間檢查器與兩個不同的開放時間案例。我寫了一個腳本,改變時間的條目,如:打開,很快打開,很快關閉等。隔夜開放時間檢查器JS
我不確定這個隔夜檢查器是否像我寫的那樣有用,因爲當日期改變時,例如從星期四到星期五,它顯示在午夜後不正確的開放時間..
我在腳本(日期和小時)中寫了兩個靜態參數來測試它,但沒有任何效果!
你能幫我把這工作嗎? 謝謝!
<script type="text/javascript">
var date = new Date();
var day = date.getDay();
var hour = date.getHours();
var day = 2;
var hour = 19;
if (day == 0 | 1 | 2 | 3 | 4 && hour == 18 | 19 | 20 | 21 | 22 | 23 | 0 | 1 | 2) {
\t var weekday = "day" + day;
var oldHTML = document.getElementById(weekday).innerHTML;
if (hour == 18 || 2) {
if (hour == 18){var newHTML = "<p><span class='label label-default'>Bald geöffnet</span></p>"; document.getElementById(weekday).innerHTML = newHTML;}
\t \t if (hour == 2){var newHTML = "<p><span class='label label-default'>Bald geschlossen</span></p>"; document.getElementById(weekday).innerHTML = newHTML;} \t \t
}
\t else {
\t \t var newHTML = "<p><span class='label label-default'>Geöffnet</span></p>";
\t \t document.getElementById(weekday).innerHTML = newHTML;
\t } \t \t
} else if (day == 5 | 6 && hour == 18 | 19 | 20 | 21 | 22 | 23 | 0 | 1 | 2 | 3 | 4) {
\t var weekday = "day" + day;
\t var oldHTML = document.getElementById(weekday).innerHTML;
if (hour == 18 || 4) {
if (hour == 18){var newHTML = "<p><span class='label label-default'>Bald geöffnet</span></p>"; document.getElementById(weekday).innerHTML = newHTML;}
\t \t if (hour == 4){var newHTML = "<p><span class='label label-default'>Bald geschlossen</span></p>"; document.getElementById(weekday).innerHTML = newHTML;} \t \t
}
\t else {
\t \t var newHTML = "<p><span class='label label-default'>Geöffnet</span></p>";
\t \t document.getElementById(weekday).innerHTML = newHTML;
\t }
}
</script>
<div class="col-md-3 col-sm-6 col-xs-12 opening_time">
<h3>Öffnungszeiten</h3>
<ul>
<li>
<p>Montag
<time id="day1" datetime-start="19" datetime-end="3">19.00 - 03:00 Uhr</time>
</p>
</li>
<li>
<p>Dienstag
<time id="day2" datetime-start="19" datetime-end="3">19.00 - 03:00 Uhr</time>
</p>
</li>
<li>
<p>Mittwoch
<time id="day3" datetime-start="19" datetime-end="3">19.00 - 03:00 Uhr</time>
</p>
</li>
<li>
<p>Donnerstag
<time id="day4" datetime-start="19" datetime-end="3">19.00 - 03:00 Uhr</time>
</p>
</li>
<li>
<p>Freitag
<time id="day5" datetime-start="19" datetime-end="5">19.00 - 05:00 Uhr</time>
</p>
</li>
<li>
<p>Samstag
<time id="day6" datetime-start="19" datetime-end="5">19.00 - 05:00 Uhr</time>
</p>
</li>
<li>
<p>Sonn- /Feiertage
<time id="day0" datetime-start="19" datetime-end="3">19.00 - 03:00 Uhr</time>
</p>
</li>
</ul>
</div>
你的條件是錯誤的,檢查每個條件,並加括號它的適用 – Li357