简体   繁体   English

如何在同一页面上的2个div中显示我的JavaScript计数器结果?

[英]How to show my javascript counter result in 2 divs on the same page?

I have a javascript counter (named clock because it counts seconds) where the results are displayed in a div: 我有一个JavaScript计数器(由于它计数秒,所以将其命名为Clock),结果在div中显示:

<div id="right">Time: <input id="clock" type="text" value="00:00" style="text-align: left; background:transparent; border-style: none; color:#ffbe5e; margin: 0px; font: 20px shanghai; width:60px;" readonly /></div>

This all works and it's displays counting the seconds. 所有这些都有效,并且显示秒数。 Now I want the same display results shown in a sec div at the same page, but how to do this? 现在,我希望以秒为单位在同一页面上显示相同的显示结果,但是该怎么做呢? Simply copy and paste the code again doesn't work. 只是再次复制并粘贴代码是行不通的。

Any suggestions? 有什么建议么?

Kind regards, 亲切的问候,

ps I didn't post the javascript code cause it's a bit too big to copy/paste it in here. ps我没有发布javascript代码,因为它太大了,无法在此处复制/粘贴。 If you need it, let me know 如果您需要它,请告诉我

如上文dgvid所建议,请确保您拥有的每个计数器都有单独的ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM