|

楼主 |
发表于 2020-8-28 09:11:57
|
显示全部楼层
本帖最后由 aaron.yang 于 2020-8-28 09:13 编辑
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- h1
- {
- text-align: center;
- color: blue;
- }
- p
- {
- font-size: large;
- }
- input
- {
- height: 35px;
- width: 250px;
- font-size: 35px;
- }
- button
- {
- height: 30px;
- width: 80px;
- }
- </style>
- <meta charset="UTF-8">
- <title>工具大师(web版)</title>
- </head>
- <body>
- <h1>工具大师</h1>
- <script type="text/javascript">
- function main()
- {
- var cmd = document.getElementById("greeting").value;
- var answer = document.getElementById("answer");
- var commands = ["/help", "/commands", "/date"];
- //console.log(cmd)
- if(cmd=="/help")
- {
- answer.innerHTML = "此功能暂未开启~";
- }
- else if(cmd=="/commands")
- {
- for(var i=0;i<commands.length;i++)
- {
- answer.innerHTML = "<ul><li>{0}</li></ul>".format(commands[i]);
- }
- // answer.innerHTML = "<ul><li>/help</li><li>/commands</li><li>/date</li></ul>"
- }
- else if(cmd=="/date")
- {
- answer.innerHTML = Date();
- }
- else
- {
- if(cmd[0]=='/')
- {
- answer.innerHTML = "没有此功能~";
- }
- else
- {
- answer.innerHTML = "指令要以"/"开头~";
- }
- }
- }
- </script>
- <p>请输入指令: </p><input id="greeting" type="text">
- <br><br>
- <button type="submit" onclick="main()">提交</button>
- <br><br>
- <main id="answer">
- <em>[no answer]</em>
- </main>
- </body>
- </html>
复制代码
我在输入框中输入"/commands"时,就出错了 |
|