qq_Sinkingsmile_1
2018-07-15 17:44
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计时器</title>
<script type="text/javascript">
var num=0;
function startCount() {
document.getElementById("count").value=num;
num=num+1;
setTimeout("startCount()",1000);
}
startCount();
</script>
</head>
<body>
<form>
<input type="text" id="count" />
</form>
</body>
</html>
<input type="text" id="count" />加个onClick="startCount()"
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>计时器</title>
<script type="text/javascript">
var num=0;
function startCount() {
document.getElementById('count').value=num;
num=num+1;
setTimeout("startCount()",1000);
}
</script>
</head>
<body>
<form>
<input type="text" id="count" onClick="startCount()" />
</form>
</body>
</html>
<!DOCTYPE html> <html> <head> <title></title> <meta charset="UTF-8"> </head> <body> <div id="count"></div> <script> window.onload = showTime; var show = document.getElementById('count'); function showTime() { var date = new Date(); let h = date.getHours(); let m = date.getMinutes(); let s = date.getSeconds(); m = checkTime(m); s = checkTime(s); show.innerHTML = h + ':' + m + ':' + s; t = setTimeout(function () { showTime(); }, 1000); } function checkTime(i) { if (i < 10) { i = '0' + i; } return i; } </script> </body> </html>
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题