问答详情
源自:8-3 计时器setInterval()

value问题

<!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>


提问者:慕丝8496262 2019-03-19 15:46

个回答

  • 慕莱坞3097671
    2019-03-19 17:19:27

    value获得的就是attime中的值,而attime是由time赋值给它的,所以value最终获得的标准的中国时间