简单的留言板功能

简单的留言板功能
<!DOCTYPE html><htmllang=“zh-CN”><head><metacharset=“UTF-8”><metahttp-equiv=“X-UA-Compatible”content=“IE=edge”><metaname=“viewport”content=“width=device-width, initial-scale=1.0”><title>简单的留言板功能</title><styletype=“text/css”>*{ margin:0; padding:0; boxsizing: borderbox;} body { backgroundimage:li搭建商城点我wcqh.cnneargradient(120deg,#84fab0 0%, #8fd3f4 100%); height:98.5vh;}.container { margin:0auto; padding:020px; maxwidth:1170px;} h1 { margin:15px0;} textarea { display: block; width:100%; height:auto; minheight:300px; lineheight:20px; marginbottom:20px; padding:5px10px; border:1px solid transparent; borderradius:2px;tran搭建商城点我wcqh.cnsition: all .3s; outline:0; resize: vertical;} textarea:focus { bordercolor:#03a9f4 !important;} button { minwidth:100px; height:38px; lineheight:38px; border:1px solid #eaeaea; color:#666; padding:018px; backgroundcolor:#fff; textalign: center; fontsize:14px; borderradius:2px; cursor: pointer; transition: all .3s;}butt搭建商城点我wcqh.cnon:hover { opacity:.8; bordercolor:#03a9f4;}.list>li { display: flex; placecontent: spacebetween; backgroundcolor:#fff; lineheight:36px; marginbottom:5px; borderradius:5px; padding:08px;}</style></head><body><divclass=“container”><h1style=textalign: center;>留言板</h1><divclass=“message”style=marginbotto搭建商城点我wcqh.cnm:20px;><textareaplaceholder=“请输入留言内容, 也可以使用快捷键Ctrl+Enter提交”></textarea><divstyle=textalign: right;><button>提交</button></div></div><ulclass=“list”></ul></div><script> let text = document.querySelector(“textarea”); let btn = document.querySelector(“button”); let list = document.querySelector(“.list”);// 监听搭建商城点我wcqh.cn提交快捷键: Ctrl+Enter text.addEventListener(keypress,function(event){if(event.key ==“\n”){ btn.click();}})// 监听点击提交按钮 btn.addEventListener(click,function(event){ submit();})function submit(){if(text.value.length ===0){ alert(留言不能为空); text.focus();returnfalse;} let itemsView =`<li><div>${text.value}</div><div>${get搭建商城点我wcqh.cnDate()}</div></li>`; list.insertAdjacentHTML(“afterbegin”, itemsView); text.value =; alert(提交成功);}function getDate(){ let date =newDate();return date.getFullYear()++ date.getMonth()++ date.getDay()++ date.getHours()+:+ date.getMinutes()+:+ date.getSeconds();}</script></body></html>

批改老师:PHPz 批改状态:合格 老师批语:做得很好

© 版权声明
THE END
喜欢就支持一下吧
点赞96 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容