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

为啥在这里&nbsp就是显示&nbsp

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>定时器</title>

<script type="text/javascript">

  var attime;

  setInterval(clock,1000)

  function clock(){

    var time=new Date();

    var week=new Array("星期日","星期一","星期二","星期三","星期四");

    attime=time.getFullYear()+"年"+time.getMonth()+"月"+time.getDate()+"日"+"&nbsp"+week[time.getDay()]+time.getHours()+"时:"+time.getMinutes()+"分:"+time.getSeconds()+"秒";

    document.getElementById("clock").value = attime;

  }

  

</script>

</head>

<body>

<form>

<input type="text" id="clock" size="50"  />

</form>

</body>

</html>


提问者:慕粉1888 2016-06-15 13:47

个回答

  • 正是泽
    2016-06-15 14:31:38
    已采纳

    少了分号;             &nbsp;           请注意分号 ;         整个是一个整体

  • potato昊
    2016-06-15 19:35:27

    加个;

  • 梅开一片
    2016-06-15 15:12:11

    &nbsp;

    少个分号,转义字符都要加分号

  • ov不后悔
    2016-06-15 14:52:56

    &nbsp;