Skip to content

Instantly share code, notes, and snippets.

@wangwen1220
Created February 19, 2014 03:04
Show Gist options
  • Select an option

  • Save wangwen1220/9085330 to your computer and use it in GitHub Desktop.

Select an option

Save wangwen1220/9085330 to your computer and use it in GitHub Desktop.
JQ: [jQuery] 左右键快速切换上下篇文章 | next prev
// [jQuery] 左右键快速切换上下篇文章
$(document).keydown(function(e) {
if (e.keyCode == 37) {
var rnt = $('a[rel="next"]');
if (rnt.length > 0) {
location.href = rnt.attr('href');
};
};
if (e.keyCode == 39) {
var rpv = $('a[rel="prev"]');
if (rpv.length > 0) {
location.href = rpv.attr('href');
};
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment