js调用方法中的方法

来源:互联网 发布:js输入框失去焦点事件 编辑:程序博客网 时间:2024/06/11 19:45
<!DOCTYPE html><html>  <head>    <title>函数调用</title>    <meta charset="utf-8">    <meta name="keywords" content="keyword1,keyword2,keyword3">    <meta name="description" content="this is my page">    <meta name="content-type" content="text/html; charset=UTF-8">    <script type="text/javascript">    var timer=null;    var num=0;    var bool=true;    function onChange() {this.shuchu=function(i){console.log(i);timer=window.setTimeout(function(){i++;num=i;shuchu(i);},1000);};if(bool){shuchu(0);}}    function doStart() {bool=false;var f=new onChange();num++;f.shuchu(num);}function doStop() {window.clearTimeout(timer);}    </script>  </head>  <body>  <input type="button" value="计数" onclick="onChange()">    <input type="button" value="开始" onclick="doStart()"/>    <input type="button" value="停止" onclick="doStop()"/>  </body></html>

1 0