admin管理员组

文章数量:1394534

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?

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?

Share Improve this question edited Aug 1, 2013 at 13:27 Noich 15.5k15 gold badges65 silver badges93 bronze badges asked Aug 1, 2013 at 13:22 scrblnrd3scrblnrd3 7,4249 gold badges36 silver badges65 bronze badges 1
  • 3 Did you import jQuery before this line? – colestrode Commented Aug 1, 2013 at 13:29
Add a ment  | 

2 Answers 2

Reset to default 8

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.

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./jquery-3.3.1.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>

should be

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

本文标签: javascriptfn is not an objectStack Overflow