Dialog close() Method
Example
Show and close a dialog window:
const dialog = document.getElementById("myDialog");
function showDialog() {
dialog.show();
}
function closeDialog() {
dialog.close();
}
Try it Yourself »
Description
The close()
method closes an HTML <dialog> object.
The close()
method is often used together with the
show()
method.
Syntax
dialogObject.close()
Browser Support
<dialog>
was introduced in HTML 5 (2014).
It is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
<dialog>
is not supported in Internet Explorer 11 (or earlier).
❮ Dialog Object