Using the lightweight library's construction material to create dialogs that essentially uses the main <dialog> , is there a way to dismiss the dialog by clicking on its background? (Direct clicking on the contents of the dialog box cannot be discarded).
<dialog>Hi</dialog> <button>show</button> document.querySelector("button").addEventListener("click", () => document.querySelector("dialog").showModal());
https://jsfiddle.net/fyjbvbqq/
Clicking anywhere on the screen when a dialog is displayed corresponds to clicking on the dialog element, so it seems that there is no easy way to determine if the background has clicked ... is there a way to do this?
source share