-2

I have a wordpress website.But I run into the following error.

custom-js.js:2 Uncaught TypeError: $(...).carousel is not a function
  at HTMLDocument. (custom-js.js:2)
  at c (jquery-1.10.1.min.js:4)
  at Object.fireWith [as resolveWith] (jquery-1.10.1.min.js:4)
  at Function.ready (jquery-1.10.1.min.js:4)
  at HTMLDocument.q (jquery-1.10.1.min.js:4)

How can I resolve this error ?

DarkMukke
  • 2,469
  • 1
  • 23
  • 31
  • have you added the reference of carousel library? – Satpal Dec 13 '18 at 11:53
  • Wordpress disables the `$` alias by default, so you need to call `jQuery(...).carousel(...)` instead. Since your script has more `$` calls, you can also wrap the entire thing in `(function($) {` and `})(jQuery);` See here: https://digwp.com/2011/09/using-instead-of-jquery-in-wordpress/ –  Dec 13 '18 at 11:55
  • Maybee 46 script tags in the page is a bit too much? I think you are loading carousel but then load jQuery again so the carousel extension is removed. – HMR Dec 13 '18 at 11:58
  • Please don't use external links they are prone to break. Add the relevant parts into the question so it remains helpful even after the external content is gone. – lilalinux Dec 13 '18 at 12:13

1 Answers1

0

Have you remembered to include the carousel library? I found you are including "owl carousel", which is initialised differently.

Owl carousel, according to their documentation, uses $element..owlCarousel(optionsObject), not $element.carousel(optionsObject).

L. Copley
  • 145
  • 9