Last active
December 13, 2023 08:47
-
-
Save Vaviloff/26454c520188b21139b943d745badb9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>Dialog demo</title> | |
| </head> | |
| <body> | |
| <button id="open">Open dialog</button> | |
| <div id="result"></div> | |
| <dialog> | |
| <form method="dialog"> | |
| <p>Tabs or spaces?</p> | |
| <button type="submit" value="tabs">Tabs</button> | |
| <button type="submit" value="spaces">Spaces</button> | |
| </form> | |
| </dialog> | |
| <script> | |
| document.querySelector("#open").addEventListener("click", () => { | |
| document.querySelector("dialog").showModal(); | |
| }); | |
| const dialog = document.querySelector("dialog"); | |
| dialog.addEventListener("close", () => { | |
| dialog.close(); | |
| document.querySelector("#result").innerText = `The result is ${dialog.returnValue}`; | |
| }); | |
| </script> | |
| <style> | |
| dialog::backdrop { | |
| background: #fff5; | |
| backdrop-filter: blur(4px); | |
| } | |
| </style> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment