<html> <head> <script type="text/javascript"> function showTime(){ var c=document.getElementById("text"); var nowTime=new Date(); c.innerHTML="time is "+nowTime.toLocaleTimeString(); } function startTime(){ setInterval("showTime()",50); }</script> </head> <body onload="startTime()"> <div id="text"></div> </body> </html> 这个程序运行良好,一个简单的clock,正常运行。我现在做一个简单的调整<html> <head> <script type="text/javascript"> function startTime(){ function showTime(){ var c=document.getElementById("text"); var nowTime=new Date(); c.innerHTML="time is "+nowTime.toLocaleTimeString(); } setInterval("showTime()",50); } </script> </head> <body onload="startTime()"> <div id="text"></div> </body> </html> 运行出现错误 ReferenceError: showTime is not defined为何会这样?showTime这个函数明明在startTime这个函数的开头部位,为何会找不到?请解释一下整个函数运行的过程。
添加回答
举报
0/150
提交
取消