js 面向对象编程 - 提示
1 <div class="notice" id="noticeBox"> 2 <div class="close-btn" title="关闭"> 3 <svg t="1574043429318" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5339" width="10" height="10"><path d="M583.168 523.776L958.464 148.48c18.944-18.944 18.944-50.176 0-69.12l-2.048-2.048c-18.944-18.944-50.176-18.944-69.12 0L512 453.12 136.704 77.312c-18.944-18.944-50.176-18.944-69.12 0l-2.048 2.048c-19.456 18.944-19.456 50.176 0 69.12l375.296 375.296L65.536 899.072c-18.944 18.944-18.944 50.176 0 69.12l2.048 2.048c18.944 18.944 50.176 18.944 69.12 0L512 594.944 887.296 970.24c18.944 18.944 50.176 18.944 69.12 0l2.048-2.048c18.944-18.944 18.944-50.176 0-69.12L583.168 523.776z" fill="#8a8a8a" p-id="5340"></path></svg> 4 </div> 5 <div class="text"></div> 6 <div class="margin-t-30 text-right" id="confirm-btn" style="display: none;"> 7 <button type="button" onclick="closeBox()" class="btn btn-white color-grey">取消</button> 8 <button type="button" id="confirmBtn" onclick="loginOut()" class="btn btn-orange">确认</button> 9 </div> 10 </div>
js 面向对象编程
1 function Notice(){ 2 this.status = ""; 3 this.tipText = ""; 4 this.confirmText = "确定"; 5 this.timer = null; 6 } 7 Notice.prototype.confirm = function (status,tipText,confirmText,callback){ 8 clearTimeout(this.timer); 9 this.confirmText = confirmText; 10 $($("#confirm-btn button")[1]).text(`${this.confirmText}`); 11 $("#confirm-btn").show(); 12 this.updateNotice(status,tipText,true); 13 } 14 Notice.prototype.updateNotice = function(status,tipText,isStop){ 15 this.status = status; 16 this.tipText = tipText; 17 $("#noticeBox").addClass(`${this.status}`).css("top","200px").css("opacity","1").find(".text").text(`${this.tipText}`); 18 if(!isStop){ 19 this.autoClose() 20 } 21 } 22 Notice.prototype.autoClose = function(){ 23 this.timer = setTimeout(()=>{ 24 this.closeBox(); 25 },6000) 26 } 27 Notice.prototype.closeBox = function(){ 28 $("#noticeBox").css("opacity","0").css("top","-999px").removeClass(`${this.status}`); 29 $("#confirm-btn").hide(); 30 } 31 let notice = new Notice(); 32 $(document).on("click","#noticeBox .close-btn",function(){ 33 notice.closeBox(); 34 })
1 .notice{ 2 position: fixed; 3 /* top: 200px; */ 4 background-color: #fff; 5 top: -999px; 6 left: 50%; 7 margin-left: -125px; 8 z-index: 9999; 9 padding: 20px; 10 border-radius: 4px; 11 width: 250px; 12 opacity: 0; 13 color: #333; 14 transform: scale(1); 15 transition: all 1.5s ease-in-out; 16 border: 1px solid #ffa066; 17 } 18 .notice.notice-success{ 19 color: #4CAF50; 20 } 21 .notice.notice-error{ 22 color: #f43636; 23 } 24 .notice.notice-info{ 25 color: #2196F3; 26 } 27 .notice.notice-warning{ 28 color: #FF9800; 29 } 30 .notice .text{ 31 text-align: left; 32 } 33 .notice .close-btn{ 34 position: absolute; 35 top: 0; 36 right: 0; 37 width: 20px; 38 height: 20px; 39 text-align: center; 40 cursor:pointer; 41 }
作者:胡倩倩0903
本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
posted on 2020-01-10 16:37 kitty20180903suzhou 阅读(144) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY