on 2 websites I have included the lightbox2-code
but on one it works, on the other not and I can't figure out the difference. on the not working site I get the error typeerror $ is not a function ... lightbox.js (78,5)
Asked
Active
Viewed 77 times
-1

mehrdadep
- 972
- 1
- 15
- 37
-
Include jQuery before all your scripts and After that define $ variable for jQuery functions. – mehrdadep Mar 29 '19 at 14:35
-
1There's not enough here for us to help. We can only speculate. Please provide more detail about both applications. – isherwood Mar 29 '19 at 15:05
1 Answers
0
Lightbox2 requires jQuery. Make sure it is loaded ahead of the Lightbox script, or use the lightbox-plus-jquery.js
file if you are not currently loading jQuery on your page. This file is located in the dist/js/
folder of the Lightbox2 package.
Here is the relevant snippet form the official docs:
Make sure jQuery, which is required by Lightbox, is also loaded.
- If you already use jQuery on your page, make sure it is loaded before lightbox.js. jQuery 1.7 or greater is required.
- If you are not currently using jQuery, I've created a packaged file that includes both Lightbox and jQuery. Include dist/js/lightbox-plus-jquery.js instead of lightbox.js.

Lokesh Dhakar
- 5,289
- 5
- 22
- 24