Getting started
Add css link to document head
<link rel="stylesheet" href="./css/_carousel.css">
Add code to document body
Make sure the class name _carousel-content is there. The top _carousel class is to initialize the carousel automatically.
<div class="_carousel">
<div class="_carousel-content">
<div class="selected">
...
</div>
<img src="..." alt="...">
<div>...</div>
...
</div>
</div>
*** If you DO NOT specify class="_carousel", you will need to initialize the carousel manually. By this, you will have init event.
<div id="exampleCarousel">
...
</div>
...
<script src="./js/_carousel.js"></script>
<script>
...
let elem = document.querySelector('#exampleCarousel');
if (elem) {
elem.addEventListener('init', evt => {
console.log(evt);
//your code here
});
new _carousel(elem);
}
</script>
</body>
Add javascript code before the closing body tab
...
<script src="./js/_carousel.js"></script>
</body>