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();    
});
相关推荐
Yeats_Liao2 天前
后台 Sidebar 伸缩交互(PC + 移动端)实现
前端·javascript·css·html5
河阿里3 天前
HTML5标准完全教学手册
前端·html·html5
We་ct3 天前
HTML5 原生拖拽 API 实战案例与拓展避坑
前端·html·api·html5·拖拽
yqcoder3 天前
vue2 和 vue3 的核心区别
html5
yuanlaile4 天前
想做智能电视App?用H5 + 跨平台也能快速上线
html5·cordova·智能电视·ionic·tv应用开发
We་ct4 天前
HTML5 原生拖拽 API 基础原理与核心机制
前端·javascript·html·api·html5·浏览器·拖拽
zimoyin4 天前
Web Components 介绍与推荐三款框架
web3·html5
方安乐4 天前
网页设计:自动适配浏览器深色/浅色模式
前端·html5
大黄说说6 天前
HTML5语义化标签:从div到article与section的进化之路
前端·html·html5
布局呆星6 天前
Vue3 笔记:过渡动画与自定义指令
javascript·css·vue.js·python·es6·html5