首页 \ 问答 \ SetTimeout和setInterval是第一个参数加上没有括号,加上没有双引号(SetTimeout and setInterval the first parameter plus no parentheses, plus no double quotes)

SetTimeout和setInterval是第一个参数加上没有括号,加上没有双引号(SetTimeout and setInterval the first parameter plus no parentheses, plus no double quotes)

<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var num=0;
function numCount(){
 document.getElementById('txt').value=num;
 num=num+1;
 setTimeout(numCount(),1000);
 }

</script>
</head>
<body>
<form>
<input type="text" id="txt" />
<input type="button" value="Start" onClick="numCount()" />
</form>
</body>
</html>

为什么要在上面的代码中为第一个参数添加括号,为什么在seTimeout中添加双引号? 那么setInterval呢?


<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var num=0;
function numCount(){
 document.getElementById('txt').value=num;
 num=num+1;
 setTimeout(numCount(),1000);
 }

</script>
</head>
<body>
<form>
<input type="text" id="txt" />
<input type="button" value="Start" onClick="numCount()" />
</form>
</body>
</html>

Why do you want to add parentheses to the first parameter in the above code, and why do you add a double quotation mark in the seTimeout? What about setInterval?


原文:https://stackoverflow.com/questions/43437152
更新时间:2022-10-22 13:10

最满意答案

好的,我解决了。 如果任何人有同样的问题,请尝试禁用CodeBlocks中的代码完成插件(插件 - >管理插件,在列表中找到'代码完成',点击'禁用')。

希望这可以帮助。


Ok, I solved it. If anyone have the same issue try disabling Code Completion plugin in CodeBlocks (Plugins -> Manage plugins, find 'Code completion' in the list, click 'Disable').

Hope this helps.

相关问答

更多
  • 点进苹果官网,点击下方的Mac os新系统El Capitan 2 进入Mac os新系统El Capitan页面介绍。 在Mac os新系统El Capitan介绍页面往下滑, 接近页面底部,但还不到底部的样子, 会看到apple beta版软件计划,
  • 有两张盘,一张是mac系统盘,是以后自己重装系统或者改密码什么的。另一张有驱动,在mac上装boot camp 分区。然后剩下的就是和普通机子一样了,不过第二张盘在win上还是要用的,还要在win上装boot camp和其他驱动
  • 别把 Mac 想得太复杂了, Mac 是最适合电脑盲的。 dmg 格式的,双击打开,把图标往 应用程序的文件夹里一拖就 OK了 其他格式的,打开后,点下一步就 OK了
  • Mac OS X是指Macintosh操作系统10,10在罗马数字里是X,每个版本用不同的大型猫科动物命名包括10.5和10.6,你可以看看百度百科对Mac OS X
  • 在回答之前先向楼上童鞋致以严重的鄙视.. 两者的功能完全一样,只是面向的系统板本不一样.有combo的可以从任何版本的Leopard更新到目标版本,而没有combo的必须从上一版本更新.简单吧~
  • 我有同样的问题。 看来这个问题与新版操作系统版本中的Ubiquity.framework缺失有关。 我设法让Xcode 6.4在OS 10.12上工作如下: 禁用系统完整性保护(SIP) 重新启动您的Mac。 在OS X启动之前,按住Command-R并保持不动,直到看到Apple图标和进度条。 发布。 这将引导你进入恢复。 从“实用工具”菜单中选择“终端”。 在提示符处输入以下内容,然后按回车键:csrutil disable 终端应显示SIP被禁用的消息。 从菜单中选择重新启动。 II。 将“OS X ...
  • 我不是MAC开发人员,但您的要求是否适合SQLite ? 这是一个关于入门的教程。 I'm not a MAC developer, but will your requirement fit SQLite? Here's a tutorial on Getting Started.
  • 如果使用Wine,则可以在OS X上加载DLL。 不能使用Java加载它们。 You can load DLLs on OS X if you use Wine. Loading them using just Java is not possible.
  • 我遇到了同样的问题。 然而,Mac OS X中的线程制作编译器设置向我展示了出路。 我发现'wxSmith'插件似乎是我麻烦的根源。 我禁用了它们:插件>管理插件 I've got the same problems. However the thread Making compiler setting stick in Mac OS X showed me the way out. I figured out the 'wxSmith' plugins seem to be the source of m ...
  • 好的,我解决了。 如果任何人有同样的问题,请尝试禁用CodeBlocks中的代码完成插件(插件 - >管理插件,在列表中找到'代码完成',点击'禁用')。 希望这可以帮助。 Ok, I solved it. If anyone have the same issue try disabling Code Completion plugin in CodeBlocks (Plugins -> Manage plugins, find 'Code completion' in the list, click ' ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。