When I try to add my products to an owl-carousel using JavaScript, the display is not correct. My HTML code looks like this:
<div class="container mt-5 mb-5" data-aos-anchor-placement="top-center">
<div class="owl-carousel">
<div class="ml-2 mr-2">
<div class="card">
<div class="cs-pic">
<div class="effect">
<div class="listProduct">
<div class="product-action-list d-flex">
<a href="product.php" title="View"><span class="fa fa-eye"></span></a>
<a href="login.php" title="Add to Favorites"><span class="fa fa-heart"></span></a>
<a href="login.php" title="Email me When the price drops"><span class="fa fa-envelope"></span></a>
</div>
</div>
</div>
<img src="imgProducts/guitar1.jpg" alt="Product" class="card-img-top">
</div>
<div class="card-body">
<h4 class="card-title text-center">
Electrical
</h4>
</div>
</div>
</div>
//more card content goes here
</div>
</div>
In my JavaScript code, I am appending new product cards dynamically to the existing carousel. However, when I do this, the carousel displays vertically instead of as a proper carousel. This is what my JavaScript code looks like:
sectionCarouselProducts.innerHTML = sectionCarouselProducts.innerHTML + `
<div class="ml-2 mr-2">
<div class="card">
//new card content added dynamically
</div>
</div>
`
The inner html is being appended to this base HTML structure:
<div class="container mt-5 mb-5" data-aos-anchor-placement="top-center">
<div class="owl-carousel carousel-products">
</div>
</div>
If anyone has any insights on why the owl carousel appears vertical after appending new content, please let me know! Thank you for your help!