I'm using jCarouselLite to create a navigation element somewhat similar to the tabbed navigation used on Panic's Coda site, but I'd like to trigger the left and right scroll on a keypress. Can this be done without modifying the jCarouselLite code? Thanks!
问问题
653 次
1 回答
1
Using the default settings, the buttons contain the classes .prev
and .next
so why not try to trigger clicks on them?
function myFunction() {
$(".prev").trigger("click");
}
If you pass in your own classes or IDs for the buttons in the options, bind to them instead.
This example will fire when you hit the left and right keyboard keys:
$(document).keyup(function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
switch(code) {
case 37: $(".prev").trigger("click"); break; // left
case 39: $(".next").trigger("click"); break; // right
}
});
于 2009-12-07T21:43:26.493 回答