Question

I'm trying out using scrollspy with bootstrap, and I'm running into some errors with it. The error console keeps returning this: TypeError: 'undefined' is not an object (evaluating '$.fn'), on line 124 of bootstrap-scrollspy.js, which is this line

var old = $.fn.scrollspy

, which is under the ScrollSpy Plugin Definition. I am using the code directly taken from this jsFiddle

Does anyone know why this is happening?

Was it helpful?

Solution

I would double check two things:

  1. Make sure you're including jQuery before you're including Bootstrap on the page.
  2. Make sure no other libraries (e.g., prototype) are overriding the $ variable.

OTHER TIPS

On your script line I assume you have removed "slim" from jQuery include. But did you remove the "integrity" checksum? if not, the integrity check is failing, and jQuery isn't loading.. (I just had this same issue).

for example this:

<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>

should be

<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>

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