Blogger Information
Blog 25
fans 0
comment 0
visits 10611
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
留言板(乞丐版)
PHui
Original
395 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>todoList: 留言板</title>
  8. <link rel="stylesheet" href="css/demo1.css" />
  9. </head>
  10. <body>
  11. <header>
  12. <div class="head">
  13. <div class="logo">
  14. <img
  15. src="http://liuyan.people.com.cn/img/logo2.7914a084.png"
  16. alt=""
  17. />
  18. </div>
  19. </div>
  20. </header>
  21. <main>
  22. <textarea
  23. type="text"
  24. onkeydown="insertComment(this)"
  25. placeholder="请输入留言"
  26. autofocus
  27. cols="100"
  28. rows="8"
  29. ></textarea>
  30. <div class="downLine"></div>
  31. <ul class="list"></ul>
  32. </main>
  33. <script>
  34. const insertComment = function (ele) {
  35. if (event.key === "Enter") {
  36. if (ele.value.length === 0) {
  37. alert("留言不能为空");
  38. ele.focus();
  39. return false;
  40. }
  41. const ul = document.querySelector(".list");
  42. ele.value += `<button onclick ="del(this.parentNode)">删除</button>`;
  43. ul.insertAdjacentHTML("afterbegin", `<li>${ele.value}<hr></li>`);
  44. ele.value = null;
  45. }
  46. };
  47. const del = function (ele) {
  48. return confirm("是否删除?") ? (ele.outerHTML = null) : false;
  49. };
  50. </script>
  51. </body>
  52. </html>

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:做的很不错, 乞丐版是谦虚了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post