html show modal dialog

    <button onclick="showModalDialog()">show modal dialog</button>
    <dialog id="dialog" onclose="onModalClose(event)">
        <header>This is a sample dialog</header>
        <form method="dialog">
            <p>What is your favorite pet animal?</p>
            <menu>
                <button value="feline">Cats</button>
                <button value="canine">Dogs</button>
                <button value="other">other</button>
            </menu>
        </form>
    </dialog>

    <script type="text/javascript">
        function showModalDialog() {
            document.querySelector('#dialog').showModal()
        }
        function onModalClose(event) {
            const value = event.target.returnValue
            console.log(value)
        }
    </script>

https://watercss.kognise.dev/#installation

posted on 2023-03-03 18:13  明天有风吹  阅读(45)  评论(0编辑  收藏  举报

导航

+V atob('d2h5X251bGw=')

请备注:from博客园