【jQuery・Bootstrap4】ハンバーガーメニューが動作しなくなる。

Bootstrap,jQuery

スポンサーリンク

サイトの改修をしていると、動いていたはずのBootstrap4を使用して作成したハンバーガーメニューが動かなくなっていた。

ブラウザの開発者ツールを見ると以下のエラーが出ていた。

Uncaught TypeError: Cannot convert object to primitive value
    at RegExp.test (<anonymous>)
    at HTMLDivElement.<anonymous> (collapse.js:346)
    at Function.each (jquery-3.5.0.min.js:2)
    at S.fn.init.each (jquery-3.5.0.min.js:2)
    at S.fn.init.a._jQueryInterface [as collapse] (collapse.js:337)
    at HTMLDivElement.<anonymous> (collapse.js:385)
    at Function.each (jquery-3.5.0.min.js:2)
    at S.fn.init.each (jquery-3.5.0.min.js:2)
    at HTMLAnchorElement.<anonymous> (collapse.js:381)
    at HTMLDocument.dispatch (jquery-3.5.0.min.js:2)

今回、改修時にjQueryを以下の"3.5.0″にしていた。

<script src="https://code.jquery.com/jquery-3.5.0.min.js" integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script>

しかし、「jquery-3.5.0」では不具合により、Bootstrapのいくつかの機能が動かなくなってしまっていたようだ。

以下の3.5.1では改善されたようなので、そちらに変更したらハンバーガーメニューは正常に動作するように戻っていた。

<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>

https://code.jquery.com/jquery/

Bootstrap,jQuery

Posted by ton