LoginSignup
2
0

More than 1 year has passed since last update.

jQueryを使わずにBootstrapのモーダルを動的に表示させる

Last updated at Posted at 2021-11-09

結論

こんな感じで書いてください。

sample.html
<script>
    window.addEventListener('load', function() {
        const modal = new bootstrap.Modal(document.getElementById('{modalのid}')) // Modalのインスタンスを作成
        modal.show() // show()メソッドを実行
    });
</script>

おまけ

Bootstrapの動的な操作を書いている記事がjQueryを使っているものばかりだったので記事を書きました。
最近BootstrapはjQueryへの依存がなくなり、ネイティブのJavaScriptでほとんどの動作ができるようになったみたいですね。

参考

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0