HTML5:dialog

JavaScript 练手小技巧:HTML5 的 dialog 标签制作对话框_dialog html-CSDN博客

html 复制代码
<dialog id="dialog">
<h2 align="center">修改</h2>
<input type="text" id="title1" placeholder="标题" value=""><p>
<input type="text" id="website1" placeholder="https://" value="https://"><p>
<center><button id="button_modify_confirm">确定</button> <button id="button_modify_cancel">取消</button></center>
</dialog>

Modal 模式可以按 ESC 关闭 dialog

javascript 复制代码
menu_modify.addEventListener('click', function(){
    menu.style.display = 'none';
    dialog.showModal();
});

点击 dialog 外部区域关闭窗口

javascript 复制代码
dialog.addEventListener("click", function(e){
    if (e.target.nodeName.toLowerCase() == "dialog") {
         this.close();
    }
});

按钮关闭窗口

javascript 复制代码
button_modify_cancel.addEventListener("click", function(e){
    dialog.close();    
});
相关推荐
摇滚侠21 小时前
12 移动端 WEB 前端 WEB 开发 HTML5 + CSS3 + 移动 WEB
前端·css3·html5
Bug-制造者2 天前
深入理解 HTML5 Web Workers:提升网页性能的关键技术解析
前端·html·html5
Simon523142 天前
常见404 500错误解析
网络·学习·servlet·html5
软件开发技术深度爱好者2 天前
HTML5+JavaScript读取DOCX 文档完整内容
前端·html5
ZC跨境爬虫4 天前
跟着 MDN 学 HTML day_34:(深入XML 中的 CDATASection 接口)
xml·前端·html·html5·媒体
一起养小猫4 天前
HTML5+CSS3+JavaScript实现高木同学圣诞树GalGame完整开发指南
javascript·css3·html5·galgame
燐妤4 天前
前端HTML编程3:初识CSS
前端·html5
ZC跨境爬虫5 天前
跟着 MDN 学 HTML day_33:(Attr 接口与属性节点的深入理解)
前端·javascript·ui·html·音视频·html5
阿赛工作室5 天前
PageAgent的价值和使用示例
javascript·html5
我命由我123456 天前
前端开发概念 - 无障碍树
javascript·css·笔记·学习·html·html5·js