abstract:按照老师的思路自己写出来了,模拟只能在线客服系统。感觉老师的思路清晰,代码简洁。很容易掌握。很感恩老师的教学以下是HTML+CSS+JS代码:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <me
按照老师的思路自己写出来了,模拟只能在线客服系统。感觉老师的思路清晰,代码简洁。很容易掌握。很感恩老师的教学
以下是HTML+CSS+JS代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .chart { width: 550px; height: 600px; margin: 20px auto; background-color: cadetblue; border: 2px solid red } .chart ul { margin: 20px auto; padding: 0; width: 500px; height: 400px; background-color: bisque } .chart li{ list-style: none; height:30px; font-size: 12px; line-height:30px; margin-top:10px; padding:5px; } .chart li:nth-child(even){ color: red; text-align: right } .chart li:nth-child(even) img{ float: right } .chart li img{ width: 30px; height: 30px; float: left; margin-right: 5px; border-radius: 50%; } .chart h3 { width: 50%; margin: 10px auto; text-align: center; height: 40px; line-height: 40px; color: white } .write { width: 500px; margin: 15px auto; } .write textarea { width: 430px; float: left; height: 40px; } .write button { float: right; width: 60px; border: none; color: white; height: 45px; background-color: green } </style> </head> <body> <div class="chart"> <h3>模拟智能在线客服系统</h3> <ul> </ul> <div class="write"> <textarea name='text'></textarea> <button>发送</button> </div> </div> <script> let ul = document.getElementsByTagName('ul')[0]; let text = document.getElementsByName('text')[0]; let btn=document.getElementsByTagName('button')[0]; let tx='<img src="images/tx.jpg"/>'; let sum=0 btn.onclick=function(){ let li = document.createElement('li'); li.innerHTML=tx+text.value; ul.appendChild(li); text.value=''; sum+=1; // 设置2秒钟后自动恢复 setTimeout(function(){ // 自动回复信息模板 let info=[ '请描述你的问题', '请您重复描述你的问题', '请您再重复一遍你的问题', '好的', '嗯,在呢', '今天太晚了,明天再说吧。', ] let li=document.createElement('li'); let Kfpic='<img src="images/tx2.jpg"/>'; let hf=info[Math.floor(Math.random()*5)]; li.innerHTML=Kfpic+hf; ul.appendChild(li); },2000) } </script> </body> </html>
Correcting teacher:韦小宝Correction time:2019-01-20 09:25:19
Teacher's summary:写的很不错 js还是很有意思的吧 js还可以写出很多好玩的东西 甚至还可以写一些小游戏 这种课后有空可以研究研究哦