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.
I tried...$(document).keydown(function(e){ if (e.keyCode == 37) { $("#next").trigger('click'); }});To trigger a link formatted similar to below...<a accesskey='n' href='URL'><img src='URL.gif' alt='Next >' title='Next >' id='next' /></a>...and not having any luck.Any ideas?
Derek Lerner
2009-12-31 23:00:37
@Derek: try putting the id #next in the A tag instead of the IMG tag.
David
2010-01-01 10:49:55
@David Thanks for the help. Unfortunately I'm still unable to trigger a link via arrow keys after changing the location of the ID to the A tag. The code @jbochi shared works for displaying an alert, I'm just not able to figure out how to get this script to select and trigger a link.
Derek Lerner
2010-01-01 18:45:30