js输入框显示时间
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script> // window.console.log(); // var ret1=window.confirm(); // var ret2=window.alert(); // var ret3=window.prompt(); // console.log(ret1,ret2,ret3); var ID; function tm() { date=new Date(); date=date.toLocaleString(); // window.console.log(date); var ele=document.getElementById("tm"); ele.value=date; } function begin() { if (ID==undefined) { tm(); ID = setInterval(tm, 1000); } var ele1=document.getElementById("btn1"); ele1.disabled="disable"; var ele2=document.getElementById("btn2"); ele2.disabled=""; } function fin() { clearInterval(ID); var ele1=document.getElementById("btn2"); ele1.disabled="disable"; var ele2=document.getElementById("btn1"); ele2.disabled=""; ID=undefined; } </script> </head> <body> <div> <input type="text" id="tm"> <button id="btn1" onclick="begin()">start</button> <button id="btn2" onclick="fin()" disabled="disable">end</button> </div> </body> </html>