摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>聊天信息列表</title> <style type="text/css"> .txt{width: 500px;h
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>聊天信息列表</title> <style type="text/css"> .txt{width: 500px;height: 600px;padding:10px;margin:0px auto;border:1px solid #eee;border-radius: 15px;} .txt-1{border:1px solid #ff6b00;border-radius: 15px;margin-bottom: 20px;} </style> </head> <body> <div> <div> <ul></ul> </div> <input type="text"> <button>发送</button> </div> <script> var ul=document.getElementsByTagName('ul')[0]; var input=document.getElementsByTagName('input')[0]; var btn=document.getElementsByTagName('button')[0]; btn.onclick=function(){ var li=document.createElement('li'); li.innerHTML=input.value; ul.appendChild(li); input.value=""; } </script> </body> </html>
先获取要操作的元素;然后添加事件。
批改老师:查无此人批改时间:2019-01-18 14:53:24
老师总结:好像只有简单的框架,是不是我没看到样式?期待你下次作业把它完善,加油。