I have:
<a id="nextPage" href="somepage.php?name=foo">Next Page</a>
When someone presses an arrow button on the keyboard, I want to redirect the user to the href contained in the anchor tag. How can I do this with javascript/jquery?
I was thinking something like this:
window.location = $('#nextPage').attr('href');
Any thoughts?
Here is a demo: http://jsfiddle.net/jasper/VprbW/2/
You can also access the
hrefattribute of one of the links like this to perform faster: