慕丝8496262
2019-03-19 15:46
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定时器</title>
<script type="text/javascript">
var attime;
function clock(){
var time = new Date();
attime = time;
document.getElementById("clock").value = attime;//这里得value获取得是哪里的值?
}
var int = setInterval(clock , 1000) ;
</script>
</head>
<body>
<form>
<input type="text" id="clock" size="50" />
</form>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>定时器</title>
<script type="text/javascript">
var attime;
function clock(){
var time = new Date();
attime = time;
document.getElementById("clock")= attime;
}
var int = setInterval(clock , 1000) ;
</script>
</head>
<body>
<form>
<input type="text" id="clock" size="50" />
</form>
</body>
</html>
value获得的就是attime中的值,而attime是由time赋值给它的,所以value最终获得的标准的中国时间
JavaScript进阶篇
468196 学习 · 21891 问题
相似问题