admin管理员组

文章数量:1277886

In Jquery I would like to know how to trigger/click an a href... link that's within a .php page. This page is dynamically generating two links that I'd like to trigger using left and right keyboard arrow keys for paging next and back through a site. The links are two images within two divs. I attempted to use this but was unable to get to work due to how the links are being created.

In Jquery I would like to know how to trigger/click an a href... link that's within a .php page. This page is dynamically generating two links that I'd like to trigger using left and right keyboard arrow keys for paging next and back through a site. The links are two images within two divs. I attempted to use this but was unable to get to work due to how the links are being created.

Share Improve this question asked Dec 31, 2009 at 21:28 Derek LernerDerek Lerner 231 silver badge3 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 8

I could do something like this:

$(document).keydown(function(e){
    if (e.keyCode == 37) { 
       alert( "left pressed" );
       return false;
    }
});

Character codes:

37 - left

38 - up

39 - right

40 - down

$('a').trigger('click');

本文标签: javascriptArrow keys keyboard navigation with JqueryStack Overflow