Created
February 19, 2014 03:04
-
-
Save wangwen1220/9085330 to your computer and use it in GitHub Desktop.
JQ: [jQuery] 左右键快速切换上下篇文章 | next prev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // [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