Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 按时间启用HTML按钮_Javascript_Html_Button_Time - Fatal编程技术网

Javascript 按时间启用HTML按钮

Javascript 按时间启用HTML按钮,javascript,html,button,time,Javascript,Html,Button,Time,我的网站上有一个HTML按钮: <button id="upload" style="display:none;"> SIGN IN </button> 登录 我需要禁用按钮,每小时25到35分钟和55到05分钟除外。如果有人能提供帮助,我将不胜感激,因为我只能找到两次javascript,而且它每天只禁用一次按钮,而不是每小时两次 非常感谢。以下是一个实施示例: <html> <head> <script> onload =

我的网站上有一个HTML按钮:

<button id="upload" style="display:none;">  SIGN IN  </button>
登录
我需要禁用按钮,每小时25到35分钟和55到05分钟除外。如果有人能提供帮助,我将不胜感激,因为我只能找到两次javascript,而且它每天只禁用一次按钮,而不是每小时两次


非常感谢。

以下是一个实施示例:

<html>
<head>
<script>
onload = function() {
    var elt = document.getElementById("upload");
    var minutes = new Date().getMinutes();
    if((minutes > 24 && minutes < 36)||(minutes > 54 && minutes < 06)) {
        elt.style.display = 'inline';
    } else {
        elt.style.display = 'none';
    }
}
</script>
<head>
    <body>
        <button id="upload" style="display:none;"> SIGN IN </button>
    </body>
</html>

onload=函数(){
var elt=document.getElementById(“上传”);
var minutes=新日期().getMinutes();
如果((分钟>24分钟&分钟<36)| |(分钟>54分钟&分钟<06)){
elt.style.display='inline';
}否则{
elt.style.display='none';
}
}
登录

您也可以使用此功能在以下两者之间进行签入:

<html>
<head>
<script>   
onload = function() {
    var element = document.getElementById("upload");
    var minutes = new Date().getMinutes();
    if (check_between(minutes,25,35) || check_between(minutes,54,06)){
        element.style.display = 'inline';
    } else {
        element.style.display = 'none';
    }

    function check_between(minutes,n1,n2){ 
      if (minutes > n1 && minutes < n2){
        return true;
      }else{
        return false;
      }
    }   
}
</script>
<head>
    <body>
        <button id="upload" style="display:none;"> SIGN IN </button>
    </body>
</html>

onload=函数(){
var元素=document.getElementById(“上传”);
var minutes=新日期().getMinutes();
如果(检查(分钟,25,35)|检查(分钟,54,06)){
element.style.display='inline';
}否则{
element.style.display='none';
}
在(分钟,n1,n2){
如果(分钟数>n1和分钟数
没有现成的功能。您需要重新迭代您找到的方法向我们展示您正在谈论的代码,我们可能能够以一种适合您的方式对其进行调整。这是我正在查看的脚本:
谢谢您的帮助,但是有没有一种方法可以使用
方法来完成,因为我已经在使用
样式。display
在其他地方,该按钮仅在按下另一个按钮后显示?谢谢你的帮助!