根据系统时间自动问好
程序员文章站
2022-12-24 13:51:40
new document 点我 ......
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> </head> <body> <button onclick='godday()'>点我</button> <div id='demo'></div> <script> //根据系统时间自动问好 document.write('点按钮会向你问好哦') function godday(){ var x=''; var time=new date().gethours(); if (8<time<13) { x='上午好'; } else if(13<time<17) { x='下午好' ; } else { x='晚上好'; } document.getelementbyid('demo').innerhtml=x; } </script> </body> </html>