Javascript 秒表插入 HTML
我一直在查看这段代码:
http:// /www.jquery4u.com/jquery-date-and-time-2/online-jquery-stopwatch/
我试图准确理解它是如何工作的,因为我想在页面上有一个计时器我'我正在努力。
我一生都无法弄清楚计时器的值添加到输入“disp”的位置以及如何将其放入常规文本而不是表单输入中。
我唯一能看到的就是:
t[6]=document.getElementById('disp');
任何人都可以帮我理解这一点吗,
谢谢
I've been looking at this code:
http://www.jquery4u.com/jquery-date-and-time-2/online-jquery-stopwatch/
I'm trying to understand exactly how it is working because I'd like a timer on a page I'm working on.
I can't for the life of me work out where the value of the timer is added to the input "disp" and how I could put this into a regular text, not a form input.
The only thing I can see that refers to it is:
t[6]=document.getElementById('disp');
Can anyone help me understand this please,
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已正确识别出它们使用 t[6] 来引用 HTML 元素。但要设置它,前面有:
由于
t[6]
是表单输入,因此他们将表单输入的value
设置为格式化时间。如果您想使用其他元素,例如,您可以改为:
Which 仅更改最后一行,以便您可以设置
div
的文本。You've correctly identified that they use t[6] to refer to the HTML element. But to set it, earlier on there is:
Since
t[6]
is the form input, they set thevalue
of the form input to the formatted time. If you wanted to use some other element, e.g.<div id="myTime"></div>
, you could say instead:Which changes only the last line, so that you may set the text of your
div
.