Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Dialog close() Method

  • Last Updated : 31 May, 2019

The DOM Dialog close() method is used to close the dialog. The Dialog element is accessed by getElementById(). It is used in HTML5.
While using this method, the user can interact with other elements on the page. It is used with Dialog show() method.



Example: This example shows the working of Dialog close() Method:

<!DOCTYPE html>
<h3> HTML | DOM Dialog close() Method</h3>
<p>Click on the below buttons to show or close the dialog window.</p>
<button onclick="showDialog()">Show dialog box</button>
<button onclick="closeDialog()">Close dialog box</button>
<dialog id="showDialog" style= "color:green">
            Welcome to GeeksforGeeks</dialog>
var gfg = document.getElementById("showDialog"); 
function showDialog() {; 
function closeDialog() { 

Before Clicking on Button:

After Clicking on Show Button:

After Clicking on Close Button:

Supported Browsers:

  • Google Chrome 37.0
  • Opera 24.0
  • Safari 6.0

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :