,那麼Javascript設置文本我的以下javascript應該告訴我的客戶何時會在特定的一天收到其包裹,例如,如果是星期天,我們會在星期一發送包裹。如果日期等於
<script>
function date() {
if (new Date().getDay() == 5) {
document.getElementById("date").innerHTML = "Order before <b>9pm</b> and receive your package <b>saturday</b>.";
document.getElementById("date1").innerHTML = "<span style="color:#000; background-color:#FFFF03; padding:5px;">Same as above.</span>";
}
if (new Date().getDay() == 6) {
document.getElementById("date").innerHTML = "Order <b>now</b> and we'll send your package <b>monday</b>.";
document.getElementById("date1").innerHTML = "<span style="color:#000; background-color:#FFFF03; padding:5px;">Same as above.</span>";
}
if (new Date().getDay() == 0) {
document.getElementById("date").innerHTML = "Order <b>now</b> and we'll send your package <b>monday</b>.";
document.getElementById("date1").innerHTML = "<span style="color:#000; background-color:#FFFF03; padding:5px;">Same as above.</span>";
}
}
window.onload = date;
</script>
<span id="date"></span>
<span id="date1"></span>
但是,如果我改變今天的數字,它不工作。
這隻能在窗口加載時運行。你如何測試這個?通過每天跑步?! –
我對最後一行感到困惑 - 「但是如果我把今天的數字改成今天,那就不行了。」這是什麼意思?你如何「改變」當天的號碼? – Jamiec
它必須每天檢查嗎?.. –