输入分钟秒倒计时

Posted 过一天日子修一天缘

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了输入分钟秒倒计时相关的知识,希望对你有一定的参考价值。

 <div class="container-fluid"> 
    <div class="main-content-inner"> 
        <div class="page-content">
         <div class="page-header"> 
            <form class="form-inline" id="searchform"> 
             <div class="form-group" style="margin-left: 10px;">
                 <label></label> 
                <input type="text" class="form-control" name="Minute" id="Minute">
                 </div> 
             <div class="form-group" style="margin-left: 10px;"> 
                <label></label> 
                <input type="text" class="form-control" name="Second" id="Second">
                 </div>
              <button type="button" class="btn btn-purple btn-sm" onclick="ok()"> 开始 </button> 
             </form>
             </div>
         <div class="row" style="height:500px;line-height:500px;vertical-align:middle;font-size:200px;color:red;text-align:center;margin-top:100px"> <p id="listview"></p> 
            </div> 
        </div>
         </div> 
    </div>
  <script>

            var t;
            var Minute;
            var Second;       
            var d;

            function ok() {
                    if ($("#Minute").val() == "0" || $("#Minute").val() == "") {
                        Minute = 0;
                    } else {
                        Minute = $("#Minute").val();
                    }
                    if ($("#Second").val() == "0" || $("#Second").val() == "") {
                        Second = 0;
                    } else {
                        Second = $("#Second").val();
                    }
                var min = "";
                if (Minute < 10) {
                    min = "0" + Minute;
                } else {
                    min = Minute + "";
                }
                var sec = "";
                if (Second < 10) {
                    sec = "0" + Second;
                } else {
                    sec = Second + "";
                }
                $("#listview").text(min + ":" + sec);
                $(".page-header").hide();
                $("#listview").show();

                setTimeout(function () {
                    begin()
                }, 1000);
               
            }

            function begin() {
               
                if (Second != 0) {
                    Second--;
                    min = "";
                    if (Minute < 10) {
                        min = "0" + Minute;
                    } else {
                        min = Minute + "";
                    }
                    sec = "";
                    if (Second < 10) {
                        sec = "0" + Second;
                    } else {
                        sec = Second + "";
                    }
                    $("#listview").text(min + ":" + sec);
                } else {
                    if (Minute > 0) {
                        Minute--;
                        Second = 59;
                        min = "";
                        if (Minute < 10) {
                            min = "0" + Minute;
                        } else {
                            min = Minute + "";
                        }
                        sec = "";
                        if (Second < 10) {
                            sec = "0" + Second;
                        } else {
                            sec = Second + "";
                        }
                        $("#listview").text(min + ":" + sec);
                    } else {
                        clearTimeout(t);
                    }
                }
                t = setTimeout(function () {
                    begin()
                }, 1000)

            }

        </script>

 

以上是关于输入分钟秒倒计时的主要内容,如果未能解决你的问题,请参考以下文章

20分求编写的电脑开机,自动弹出倒计时关机的代码!

24 小时倒计时计时器,带有三个单独的文本视图,分别显示小时、分钟、秒

日期选择器中的小时:分钟:秒如何快速

java 中 倒计时 一分钟 怎么写?

html里video只有几十秒,可以改成几分钟的播放时间吗?

Android 倒计时(时间戳转换天小时分钟秒)