Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2022年3月.
close() は HTMLDialogElement インターフェイスのメソッドで、このダイアログ (<dialog>) を閉じます。 引数としてオプションの文字列を渡すことができ、このダイアログの returnValue を更新します。
文字列で、このダイアログの HTMLDialogElement.returnValue を更新する値を表します。
なし (undefined)。
次の例は単純なボタンですが、クリックするとフォームを含む <dialog> を showModal() メソッドで開きます。 そこから X ボタンをクリックしてダイアログを閉じたり( HTMLDialogElement.close() メソッドで)、submit ボタンでフォームを送信したりすることができます。
[X] ボタンが type="submit" であったなら、JavaScript を必要とせずにダイアログが閉じられたはずです。 フォームを送信すると、フォームのメソッドが dialog であれば、それが入った <dialog> を閉じるので、「閉じる」ボタンは必要ありません。
| HTML # dom-dialog-close-dev |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年9月20日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.