简体   繁体   中英

How can I programatically get control of slick.js carousel?

Normally I get control of carousels ( control you ask, means the state where I can use my arrow keys to slide them ) via clicking slick.js carousels.

But I'm trying to do this with javascript code, to implement more flexible interface in my project.

Is this carousel control acquisition can be implemented programmatically? I have tried $('#my-slick-carousel').focus() but it didn't worked.

Any workarounds even not specific to the slick.js are OK, as it seems like it's a problem of delegating keypress events to the carousel jquery objects.

You were so close with your original solution attempt.

Instead of $('#my-slick-carousel').focus() , you should use $('#my-slick-carousel').find('.slick-list').focus() , because the keyboard event handlers are registered on the .slick-list element, instead of the root carousel element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM