js计时器,点击开始计时,再点击停止


 点击倒计时开始,点击停止,再次点击又开始,再点停止...

 <i id="OneToOne_ShowWaitTime">39</i>秒
 <em onclick="timeOpen();">开始</em>
 <em onclick="timeClose();">结束</em>
                    <script>
                        var c,t;
                        function GetBack() {
                            c--;
                            $("#OneToOne_ShowWaitTime").text(c);
                            if(c==0){
                                console.log("stop");
                                return;
                            }
                            t=setTimeout("GetBack()",1000);
                            console.log("秒选择" + c);
                        }

                        function timeOpen(){
                            c = $("#M_waitInterval li.M_current").attr("value");
                            GetBack();
                        }

                        function timeClose(){
                            clearInterval(t);
                            t = null;
                        }
                    </script>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM