I’d like the user to be able to load the next or previous page when they press left or right on the keyboard. The next and previous links for each page are contained within two buttons.
The html…
<a href="/page-link-prev" class="prev button">< Prev</a>
<a href="/page-link-next" class="next button">Next ></a>
Some jquery I found that registers the right key presses, but doesn’t change the url obviously, it just shows an alert.
$(function() {
$(document).keyup(function(e) {
switch(e.keyCode) {
case 37 : alert('You pressed Left'); break;
case 39 : alert('You pressed Right'); break;
}
});
});
You can use
.load()to load from a URL to a portion of the page.I’m assuming you have a specific
divyou want to refresh w page contents, and you don’t want to refresh the entire pageOr, if you want to refresh the entire page you can use
window.locationYou can replace
#pagewith the element you are refreshing.