Carousel Sample Code
-
Hi,
I’m running into issues trying to get the carousel to work by using sample code on https://getbootstrap.com/docs/4.0/components/carousel/. It displays OK except the animations don’t work. Upon clicking the controls, it throws errors “Uncaught TypeError: Cannot read property ‘offsetWidth’ of undefined at Carousel.slide yadayadayada”. I have googled for a bit and people talks about the ‘active’ class and whatnot, didn’t change a thing for me. Someone said about delaying the script to after the elements have been loaded, I tried this, then it indicated that jQuery isn’t loaded for some reason. The following is my test code placed on home as a static page, would appreciate it if you can shed some light on it! Or share the source code to your demo page, I think that helps a lot too… I’m using the child theme btw.
—
<div id=”carouselExampleIndicators” class=”carousel slide”>-
<li data-target=”#carouselExampleIndicators” data-slide-to=”0″ class=”active”>
<li data-target=”#carouselExampleIndicators” data-slide-to=”1″>
<li data-target=”#carouselExampleIndicators” data-slide-to=”2″><div class=”carousel-inner”>
<div class=”carousel-item active”>
<img class=”d-block w-100″ src=”/wp-content/uploads/2019/08/header.jpg
” alt=”First slide”>
<div class=”carousel-caption d-none d-md-block”>
<h5>Caption Image 1</h5>
<p>This is description for image 1</p>
</div>
</div>
<div class=”carousel-item”>
</div>
<div class=”carousel-item”>
<img class=”d-block w-100″ src=”/wp-content/uploads/2019/08/header2.jpg
” alt=”Third slide”>
</div>
</div>
<span class=”carousel-control-prev-icon” aria-hidden=”true”></span>
<span class=”sr-only”>Previous</span>
<span class=”carousel-control-next-icon” aria-hidden=”true”></span>
<span class=”sr-only”>Next</span>
</div>
<script type=”text/javascript”>
$(‘.carousel’).carousel()
</script>`The page I need help with: [log in to see the link]
- The topic ‘Carousel Sample Code’ is closed to new replies.