最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Owl carousel - TypeError: this.$element.attr(...) is undefined - Stack Overflow

programmeradmin1浏览0评论

On my wordpress site i use jQuery 1.12.4 together with owl carousel 2.2. When i load an carousel i get the following error:

TypeError: this.$element.attr(...) is undefined

The carousel is not working. jQuery is loadad in the header and owl carousel in the footer. I call owl carousel in a js file which is loadad after the owl carousel js:

jQuery(document).ready(function($) {
    $("#services-slider").owlCarousel();
});

On my wordpress site i use jQuery 1.12.4 together with owl carousel 2.2. When i load an carousel i get the following error:

TypeError: this.$element.attr(...) is undefined

The carousel is not working. jQuery is loadad in the header and owl carousel in the footer. I call owl carousel in a js file which is loadad after the owl carousel js:

jQuery(document).ready(function($) {
    $("#services-slider").owlCarousel();
});
Share Improve this question asked Feb 24, 2017 at 14:41 public9nfpublic9nf 1,4093 gold badges20 silver badges52 bronze badges 2
  • 2 Could you please break this down into a codepen? That would be helpful. – SinDeus Commented Feb 24, 2017 at 14:52
  • It has someting to do with the version of owl carousel. I now use an old owl carousel version and it works. – public9nf Commented Feb 24, 2017 at 15:25
Add a ment  | 

2 Answers 2

Reset to default 7

Just add any class to your #services-slider element. For examle

<div id="services-slider" class="owl-carousel">
  ....
</div>

Just minute ago have the same problem on Wordpress...

Look:

  1. id="services-slider" - must be only ONE element with id="services-slider" on page
  2. the element id="services-slider" must have class="owl-carousel"
发布评论

评论列表(0)

  1. 暂无评论