Keyboard arrow keys navigation with Easy Slider 1.7

若如初见. 提交于 2019-12-11 16:01:57

问题


I'm trying to edit the Easy Slider to allow the keyboard's arrow keys to navigate the slideshow.

I tried editing the javascript's animate function from:

default:
t = dir;
break;

...to:

default:
t = parseInt(dir);
break;

...but that didn't work.

Does anyone know how to use the keyboard's arrow keys to navigate this slideshow?


回答1:


Assuming your next and prev links have IDs of #next and #prev:

$(document).keydown(function(e){
    if (e.keyCode == 39) { 
       $('a#next').trigger('click');
    }

    else if (e.keyCode == 37) {
         $('a#prev').trigger('click');
    }
});

I'm also not familiar with easy slider, but if they have a way to programmatically switch the slides back and forth, then you could swap out the triggers with those. The posted solution will work fine though.



来源:https://stackoverflow.com/questions/6221591/keyboard-arrow-keys-navigation-with-easy-slider-1-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!