
エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
属性を与えるだけで画像をモーダル化できるコード【コピペ】 - Qiita
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
属性を与えるだけで画像をモーダル化できるコード【コピペ】 - Qiita
/**モーダルのDOM生成 */ const img_modal = document.querySelectorAll('[modal-image]'); /*activeク... /**モーダルのDOM生成 */ const img_modal = document.querySelectorAll('[modal-image]'); /*activeクラスを付与*/ img_modal.forEach(function(index) { index.addEventListener('click', openModal); }); /** * DOM生成の後、activeクラスを追加 */ function openModal() { this.parentElement.appendChild(makeModal(this)); window.setTimeout(() => { this.parentElement.getElementsByClassName('gm-modal')[0].classList.add('active'); }, 10); co