onclick怎样调用动态js函数?
发布网友
发布时间:2023-05-19 23:29
我来回答
共1个回答
热心网友
时间:2024-11-24 05:54
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="times"></div>
<br/>
<input type="button" value="Click" id="click" onclick="ourtimes();" />
</body>
<script>
function ourtimes(){
setInterval(autototime,1000);
}
function autototime()
{
var begintime=new Date(localStorage.getItem("btime"));
var nowtime = new Date();
var t=parseInt((nowtime.getTime()-begintime.getTime())/1000);
d=parseInt(t/3600/24);
h=parseInt((t/3600)%24);
m=parseInt((t/60)%60);
s=parseInt(t%60);
document.getElementById("times").innerHTML="已经开始了:"+d+"天 "+h+"时"+m+"分"+s+"秒";
}
</script>
</html>