据id,name,标签名,name属性,class属性,css选择器来获取元素最后一天望老师作业通过

Original 2019-03-25 01:11:26 317
abstract:<!doctype html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewp

<!doctype html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport"           content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">     <meta http-equiv="X-UA-Compatible" content="ie=edge">     <title>在线聊天系统</title>     <style type="text/css">         div:nth-child(1){             width: 450px;             height: 650px;             background-color: lightblue;             margin: 30px auto;             color: #333;             box-shadow: 2px 2px 2px #808080;         }         h2{             text-align: center;             margin-bottom: -10px;         }         div:nth-child(2){             width: 400px;             height: 650px;             border: 4px double green;             background-color: #efefef;             margin: 20px auto 10px;         }         ul{             list-style: none;             line-height: 2em;             overflow: hidden;             padding: 15px;         }         table{             width: 90%;             height: 80px;             margin: auto;         }         textarea{             border: none;             resize: none;             background-color: lightyellow;         }         button{             width: 60px;             height: 40px;             background-color: seagreen;             color: white;             border: none;         }         button:hover{             cursor: pointer;             background-color: orange;         }     </style> </head> <body>     <div>         <h2>在线聊天</h2>         <div contenteditable="true">             <ul>                 <li></li>             </ul>         </div>         <table>             <tr>                 <td align="right"><textarea name="text" id="" cols="50" rows="4"></textarea></td>                 <td align="left"><button type="button">发送</button></td>             </tr>         </table>     </div>     <script type="text/javascript">         var btn=document.getElementsByTagName('button')[0];         var text=document.getElementsByName('text')[0];         var list=document.getElementsByTagName('ul')[0];         var sum=0;         btn.onclick=function () {             if (text.length===0){                 alert('客官是不是忘记输入内容了');                 return false;             }             var userComment=text.value;             text.value='';             var li=document.createElement('li');             li.innerHTML=userComment;             var userPic='<img src="1111111.jpg" width="30" style="border-radius: 50%">';             li.innerHTML=userPic+' '+userComment;             list.appendChild(li);             sum+=1;             setTimeout(function () {                 var info=[                     '你好,我是中文网客服',                     '有事请留言或拨打热线',                     '请你拨打电话,                     '欢迎你的光临',                     '好的 谢谢'                 ];                 var temp=info[Math.floor(Math.random()*3)];                 var reply=document.createElement('li');                 var kefuPic='<img src="hyd.png" width="30" style="border-radius: 50%">';                 reply.innerHTML=kefuPic+' '+'<span style="color: red">'+temp+'</span>';                 list.appendChild(reply);                 sum+=1;             },2000);             if (sum>10){                 list.innerHTML='';                 sum=0;             }         }     </script> </body> </html>


Correcting teacher:天蓬老师Correction time:2019-03-25 09:26:29
Teacher's summary:下次记得代码格式化再提交, 这次暂时过, 下不为例

Release Notes

Popular Entries