Question

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")
Was it helpful?

Solution

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")

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top