賦值中添加空格疑問
<!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.getHours()?+" 分:"+time.getMinutes()?+" 秒:"+?time.getSeconds(); ????document.getElementById("clock").value?=?attime; ??} ??var?actTime?=?setInterval(clock,100); </script> </head> <body> <form> <input?type="text"?id="clock"?size="50"??/> </form> </body> </html>
請問這段代碼的問題在哪,為什么空格不能正常顯示出來???顯示出來的時 ,菜雞求解,勿噴。。。
2016-12-06
可以直接這樣加空格,? attime= "時:" + time.getHours() +" ? ? 分:"+time.getMinutes() +" ? 秒:"+ time.getSeconds();,至于為什么錯,沒搞太明白。