Topic: Beginner question
stefanvd priority asked 1 year ago
Hi!
I have a beginner question. I use the Multi carousel plugin and would like to change options in JS or jQuery, let's say 4 images instead of the default of 3. Not with data attributes but with JS or jQuery. The documentation says:
Options
Options can be passed via data attributes, JavaScript, or jQuery. For data attributes, append the option name to data-mdb-, as in data-mdb-interval="".
And then for example the amount of items: items -- Number / String -- 3 -- Defines number of visible items.
My question:
How can I set this option in my JS?
I tried:
const multiCarousel = document.getElementById('carousel'); const multiCarouselInstance = MultiCarousel.getInstance(multiCarousel); multiCarouselInstance.items(4);
And I tried:
$('#carousel').multiCarousel({ items: 5, });
This is giving the error:
Uncaught TypeError: $(...).multiCarousel is not a function
Thanks!
Kamila Pieńkowska staff answered 1 year ago
I've prepared a snippet for you: https://mdbootstrap.com/snippets/standard/kpienkowska/5736275
stefanvd priority answered 1 year ago
In addition,
the carousel is working fine, so I assume that I added the needed scripts correctly,
they are in the DOM, (before the </body>
).
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.4.2
- Device: pc
- Browser: chrome
- OS: win10
- Provided sample code: No
- Provided link: No