发布微博,体现增删查改
css
*{margin: 0; padding: 0;list-style: none;} div{width: 500px;border:1px solid #ccc;margin:50px auto;padding: 10px 0 20px 10px;} ul{padding-left: 70px;} li{border-bottom:1px dashed #ccc;line-height: 40px;} li a{width: 48px;height: 23px;border-radius:4px;margin-top: 12px;text-align: center;line-height: 23px;background-color:pink;cursor: pointer;float:right;margin-right: 6px;text-decoration: none;color:black;} li:hover a{color:red;} textarea{width: 360px;height: 270px;resize: none;}
html
<div> <span>微博内容</span> <textarea></textarea> <button>发布</button> <ul></ul> </div>
js
$('button').click(function(event) { var txt = $('textarea').val(); var tx = $('textarea'); var l = $('<li><span>'+txt+'</span><a href="javascript:;" class="aa">删除</a></li>'); if($.trim(txt)==''){ alert('请输入内容'); tx.focus().val(''); }else{ if($.trim(txt)==$('li:first span').text()){ //判断第一条来确认是否重复提交了 alert('请勿重复提交'); tx.focus().val(''); } else{ $('ul').prepend(l); $('li:first').hide().slideDown(300); tx.focus().val(''); } } }); $(document).on('click', '.aa', function(event) { var Mythis = $(this); $(this).parent().slideUp(300); setTimeout(function(){ $(Mythis).parent().remove(300); },300) });
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?