JavaScript provides two
built-in methods for the
<dialog>
element:
show()
: This method opens
the dialog box,
making it visible.
close()
: This method closes
the dialog box, hiding it.
These methods, help us add
interactivity by allowing
users to open and close
the dialog box as desired.
Let us take a look at an example
where we use JavaScript to control
the dialog element: