<div class="wrap">
  <dialog id="js-dialog">
    ダイアログの文章です
    <button id="js-dialog-close">閉じる</button>
  </dialog>
  <input type="text"><br>
  <button id="js-dialog-show-modal">showModal()</button>
  <button id="js-dialog-show">show()</button>
</div>
var showModalButton = document.getElementById('js-dialog-show-modal');
var showButton = document.getElementById('js-dialog-show');
var closeButton = document.getElementById('js-dialog-close');
var dialog = document.getElementById('js-dialog');

showModalButton.addEventListener('click', function() {
  dialog.showModal();
});

showButton.addEventListener('click', function() {
  dialog.show();
});

closeButton.addEventListener('click', function() {
  dialog.close();
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js