Last active
September 28, 2021 18:31
-
-
Save greggman/d8f2de7666b5ea6b2427f63c66603657 to your computer and use it in GitHub Desktop.
<dialog> element
This file contains 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
/*bug-in-github-api-content-can-not-be-empty*/ |
This file contains 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
<dialog id="myDialog"> | |
<div>this is a dialog</div> | |
<button id="close" type="button">close</button> | |
</dialog> | |
<button id="show" type="button">show dialog</button> | |
This file contains 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
const dialogElem = document.querySelector('#myDialog'); | |
const buttonElem = document.querySelector('#show'); | |
const closeElem = document.querySelector('#close'); | |
closeElem.addEventListener('click', (e) => { | |
dialogElem.close(); | |
}); | |
buttonElem.addEventListener('click', () => { | |
dialogElem.showModal(); | |
}); |
This file contains 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
{"name":"<dialog> element","settings":{},"filenames":["index.html","index.css","index.js"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment