[英]Displaying a variable from a javascript file onto a html page
Trying to show a the time taken to solve a puzzle but I can't seem to show the time taken on html This is my javascript code for it:试图显示解决难题所需的时间,但我似乎无法显示 html 所需的时间 这是我的 javascript 代码:
var timer;
var minRem = 5;
var secRem = 0;
It goes through many functions but the variable names remain the same它经过许多功能,但变量名称保持不变
My html code looks like this:我的 html 代码如下所示:
<script type ="text/javascript" src="Timer2.js">
</script>
<h3><p>Your time taken to escape was: </p></h3>
<script>document.write(minRem)</script>
The top line is me trying to connect to my JS file for the timer I think it is something to do with the document.write最重要的是我试图为计时器连接到我的 JS 文件,我认为这与 document.write 有关
<h3><p>Your time taken to escape was: </p></h3><span id="time"></span>
in Timer.js在 Timer.js 中
timeTaken = 30; // this is not relevant to the question
document.getElementById("time").innerText = timeTaken;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.