문제

I'm using bootstrap to collapse parts of my website. It all works fine. But when I try to control the behaviour manually by javascript, it does not work

for example when I do this:

 $(".collapse").collapse('hide');

or exactly this:

  $(".collapse").each(function () {
            if (localStorage.getItem(this.id)) {
                $(this).collapse('hide');
            }

it does not work. I get this error: Object doesn't support property or method 'collapse' bootstrap.

I saw similar examples online. What am I doing wrong? Thanks for any help.

Update:

The Problem was related to different jquery-versions in my asp.net mvc project. Removing this line of code from _Layout.cshtml fixed it:

   @Scripts.Render("~/bundles/jquery")
도움이 되었습니까?

해결책

The Problem was related to different jquery-versions in my asp.net mvc project. Removing this line of code from _Layout.cshtml fixed it:

@Scripts.Render("~/bundles/jquery")

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top