送信ボタンを1日に何回か非表示にしたい。1日に複数回送信ボタンを非表示にする
以下のコードは時々動作しますが、時々動作しません。昨日のコードは機能しましたが、今日のコードは機能しません。私は問題がどこにあるのか理解できません。
<script>
window.addEventListener("load", function() {
// Check time and update the button's state every second.
setInterval(updateSubmitButtonState, 1000);
}, false);
function updateSubmitButtonState() {
var timezone = "Asia/Calcutta";
var currentTime = new Date();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var t =currentTime.getHours() + ":" + currentTime.getMinutes();
if (t >= '10:00' && t <= '10:20' ||
t >= '11:00' && t <= '11:20' ||
t >= '13:00' && t <= '13:20' ||
t >= '15:15' && t <= '15:25' ||
t >= '17:30' && t <= '17:40' ||
t >= '19:00' && t <= '19:10' ||
t >= '20:30' && t <= '20:40') {
$("#submit").css("display", "none");
} else {
$("#submit").css("display", "block");
}
}
</script>
<input type="submit" id="submit" name="submit">
't> = '10:00 '.....'は文字列比較のようですが、時間を比較する必要があります。時間の比較については、このリンクをご確認ください https://stackoverflow.com/questions/6212305/how-can-i-compare-two-time-strings-in-the-format-hhmmss – brk
あなたは 'number'と'string'。 – gurvinder372